aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Schaefer <fschaefer.oss@googlemail.com>2014-01-19 16:48:35 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-02-04 13:43:05 -0500
commit123a17d1427a2d7ad9142df1f6543c578864a0dd (patch)
treef8747e8fa247f98be7b79d356753021524a9fd58
parent8ae8cd6c3e2519128224c2fce0dbfd7a9e32c66c (diff)
[media] em28xx-i2c: fix the error code for unknown errors
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 Chehab's tests related to i2c clock stretching and return -EIO for the rest. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--drivers/media/usb/em28xx/em28xx-i2c.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c
index bd8101dfda7c..ba6433c3a643 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,
226 * (even with high payload) ... 226 * (even with high payload) ...
227 */ 227 */
228 } 228 }
229 if (i2c_debug) 229
230 em28xx_warn("write to i2c device at 0x%x timed out (status=%i)\n", 230 if (ret == 0x02 || ret == 0x04) {
231 addr, ret); 231 /* NOTE: these errors seem to be related to clock stretching */
232 return -ETIMEDOUT; 232 if (i2c_debug)
233 em28xx_warn("write to i2c device at 0x%x timed out (status=%i)\n",
234 addr, ret);
235 return -ETIMEDOUT;
236 }
237
238 em28xx_warn("write to i2c device at 0x%x failed with unknown error (status=%i)\n",
239 addr, ret);
240 return -EIO;
233} 241}
234 242
235/* 243/*
@@ -279,8 +287,17 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len)
279 return -ENXIO; 287 return -ENXIO;
280 } 288 }
281 289
282 em28xx_warn("unknown i2c error (status=%i)\n", ret); 290 if (ret == 0x02 || ret == 0x04) {
283 return -ETIMEDOUT; 291 /* NOTE: these errors seem to be related to clock stretching */
292 if (i2c_debug)
293 em28xx_warn("write to i2c device at 0x%x timed out (status=%i)\n",
294 addr, ret);
295 return -ETIMEDOUT;
296 }
297
298 em28xx_warn("write to i2c device at 0x%x failed with unknown error (status=%i)\n",
299 addr, ret);
300 return -EIO;
284} 301}
285 302
286/* 303/*