Subject: Re: mpc-i2c.c in 2.6

From: "Mark A. Greer" <[email-masked]>
Date: Thu, 13 Jan 2005 14:33:10 -0700

Kumar Gala wrote:

> Adrian,
>
> I was wondering if you had any opinions on the timeout between 
> transactions in drivers/i2c/busses/mpc-i2c.  Looking at it, we 
> currently set the timeout between transactions to 1 second (HZ).  Any 
> reason its this high?
>
> on 85xx, I'm able to set it to HZ/100 w/o any really issue.

This is just an FYI since I've been in this code recently.  You can 
change the timeout from userspace with an ioctl.  Something like this 
should do it:

static char *usage_msg = "Usage: set_timeout <timeout value>\n";

int main(int argc, char **argv)
{
        uint    timeout;
        int     file;

        if (argc != 2) {
                fprintf(stderr, usage_msg);
                return 1;
        }

        timeout = strtoul(argv[1], NULL, 0);

        if ((file = open("/dev/i2c/0", O_RDWR)) < 0) {
                printf("Can't open device, errno: %d (%s)\n",
                        errno, strerror(errno));
                return 1;
        }

        if (ioctl(file, I2C_TIMEOUT, &timeout) < 0) {
                printf("Can't do TIMEOUT: %s\n", strerror(errno));
                return 1;
        }

        return 0;
}