Commit e63b009d6e "em28xx-i2c: Fix error code for I2C error transfers" changed
the code to return -ETIMEDOUT on all unknown errors.
But the proper error code for unknown errors is -EIO.
So only report -ETIMEDOUT in case of the errors 0x02 and 0x04, which are 
according
to Mauro Carvalho Chehabs tests related to i2c clock stretching and return -EIO
for the rest.

Signed-off-by: Frank Schäfer <fschaefer....@googlemail.com>
---
 drivers/media/usb/em28xx/em28xx-i2c.c |   29 +++++++++++++++++++++++------
 1 Datei geändert, 23 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c 
b/drivers/media/usb/em28xx/em28xx-i2c.c
index bd8101d..ba6433c 100644
--- a/drivers/media/usb/em28xx/em28xx-i2c.c
+++ b/drivers/media/usb/em28xx/em28xx-i2c.c
@@ -226,10 +226,18 @@ static int em28xx_i2c_send_bytes(struct em28xx *dev, u16 
addr, u8 *buf,
                 * (even with high payload) ...
                 */
        }
-       if (i2c_debug)
-               em28xx_warn("write to i2c device at 0x%x timed out 
(status=%i)\n",
-                           addr, ret);
-       return -ETIMEDOUT;
+
+       if (ret == 0x02 || ret == 0x04) {
+               /* NOTE: these errors seem to be related to clock stretching */
+               if (i2c_debug)
+                       em28xx_warn("write to i2c device at 0x%x timed out 
(status=%i)\n",
+                                   addr, ret);
+               return -ETIMEDOUT;
+       }
+
+       em28xx_warn("write to i2c device at 0x%x failed with unknown error 
(status=%i)\n",
+                   addr, ret);
+       return -EIO;
 }
 
 /*
@@ -279,8 +287,17 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 
addr, u8 *buf, u16 len)
                return -ENXIO;
        }
 
-       em28xx_warn("unknown i2c error (status=%i)\n", ret);
-       return -ETIMEDOUT;
+       if (ret == 0x02 || ret == 0x04) {
+               /* NOTE: these errors seem to be related to clock stretching */
+               if (i2c_debug)
+                       em28xx_warn("write to i2c device at 0x%x timed out 
(status=%i)\n",
+                                   addr, ret);
+               return -ETIMEDOUT;
+       }
+
+       em28xx_warn("write to i2c device at 0x%x failed with unknown error 
(status=%i)\n",
+                   addr, ret);
+       return -EIO;
 }
 
 /*
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to