mpc-i2c.c in 2.6

Mark A. Greer mgreer at mvista.com
Fri Jan 14 08:33:10 EST 2005


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;
}





More information about the Linuxppc-embedded mailing list