]> Pileus Git - ~andy/linux/commitdiff
[media] em28xx-i2c: relax error check in em28xx_i2c_recv_bytes()
authorFrank Schaefer <fschaefer.oss@googlemail.com>
Sun, 10 Mar 2013 10:25:25 +0000 (07:25 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 18 Mar 2013 23:18:29 +0000 (20:18 -0300)
It turned out that some devices return less bytes then requested via i2c when
ALL of the following 3 conditions are met:
- i2c bus B is used
- there was no attempt to write to the specified slave address before
- no device present at the specified slave address
With the current code, this triggers an -EIO error and prints a message to the
system log.
Because it can happen very often during device probing, it is better to ignore
this error and bail out silently after the follwing i2c transaction success
check with -ENODEV.

[mchehab@redhat.com: a small CodingStyle fix]
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/usb/em28xx/em28xx-i2c.c

index d4a48cb1202e79df9217bf886d0dcfd778c686ad..de9b2086ab2df919ff8ed9124d889d4a7728bc68 100644 (file)
@@ -227,18 +227,18 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len)
 
        /* Read data from i2c device */
        ret = dev->em28xx_read_reg_req_len(dev, 2, addr, buf, len);
-       if (ret != len) {
-               if (ret < 0) {
-                       em28xx_warn("reading from i2c device at 0x%x failed "
-                                   "(error=%i)\n", addr, ret);
-                       return ret;
-               } else {
-                       em28xx_warn("%i bytes requested from i2c device at "
-                                   "0x%x, but %i bytes received\n",
-                                   len, addr, ret);
-                       return -EIO;
-               }
+       if (ret < 0) {
+               em28xx_warn("reading from i2c device at 0x%x failed (error=%i)\n",
+                           addr, ret);
+               return ret;
        }
+       /* NOTE: some devices with two i2c busses have the bad habit to return 0
+        * bytes if we are on bus B AND there was no write attempt to the
+        * specified slave address before AND no device is present at the
+        * requested slave address.
+        * Anyway, the next check will fail with -ENODEV in this case, so avoid
+        * spamming the system log on device probing and do nothing here.
+        */
 
        /* Check success of the i2c operation */
        ret = dev->em28xx_read_reg(dev, 0x05);