Hi Graham,
while trying to understand why i2c is not working I think there is something wrong with both my original - and probably with your patch.

For example

http://tomoyo.sourceforge.jp/cgi-bin/lxr/source/drivers/i2c/busses/i2c-at91.c

uses the if(ret) return ret; variant like the original. But their xfer_read() and xfer_write() functions have a different return value semantics. They either return 0 if transfer is complete or -ETIMEDOUT. Nothing else.

The JZ version (at least the one I have in my project):

- returns -ENODEV on timeout
- otherwise returns how many bytes have NOT been transferred (is 0 if ok but positive else)

So your condition can never be true but the original one also returns a bad value from i2c_jz_xfer (if # of bytes remaining is > 0). It should just return the number of successful messages.

Maybe

                        if (i2c_get_data(buf, 0) < 0)
                                break;

should better be a

                        if (i2c_get_data(buf, 0) < 0)
                                goto L_timeout;

What do you think?

Nikolaus

Am 04.05.2010 um 08:31 schrieb Graham Gower:


                                ret = xfer_write(pmsg->addr,  pmsg->buf, 
pmsg->len);
                        }
-                       if (ret)
-                               return ret;
+                       if (ret != pmsg->len)
+                               return -1;
                        /* Wait until transfer is finished */
                }


_______________________________________________
Mipsbook-devel mailing list
Mipsbook-devel@linuxtogo.org
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/mipsbook-devel

Reply via email to