aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Schaefer <fschaefer.oss@googlemail.com>2013-03-10 06:25:25 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-18 19:18:29 -0400
commit7f6301d1257505d35e87ef1cb8eeee268e63a123 (patch)
tree17fa90a1374d48dc32adf6eaf3aec7633886eac1
parent195281d0dc6a2fc1824d5da9abd2924bce0fa698 (diff)
[media] em28xx-i2c: relax error check in em28xx_i2c_recv_bytes()
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>
-rw-r--r--drivers/media/usb/em28xx/em28xx-i2c.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c
index d4a48cb1202e..de9b2086ab2d 100644
--- a/drivers/media/usb/em28xx/em28xx-i2c.c
+++ b/drivers/media/usb/em28xx/em28xx-i2c.c
@@ -227,18 +227,18 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len)
227 227
228 /* Read data from i2c device */ 228 /* Read data from i2c device */
229 ret = dev->em28xx_read_reg_req_len(dev, 2, addr, buf, len); 229 ret = dev->em28xx_read_reg_req_len(dev, 2, addr, buf, len);
230 if (ret != len) { 230 if (ret < 0) {
231 if (ret < 0) { 231 em28xx_warn("reading from i2c device at 0x%x failed (error=%i)\n",
232 em28xx_warn("reading from i2c device at 0x%x failed " 232 addr, ret);
233 "(error=%i)\n", addr, ret); 233 return ret;
234 return ret;
235 } else {
236 em28xx_warn("%i bytes requested from i2c device at "
237 "0x%x, but %i bytes received\n",
238 len, addr, ret);
239 return -EIO;
240 }
241 } 234 }
235 /* NOTE: some devices with two i2c busses have the bad habit to return 0
236 * bytes if we are on bus B AND there was no write attempt to the
237 * specified slave address before AND no device is present at the
238 * requested slave address.
239 * Anyway, the next check will fail with -ENODEV in this case, so avoid
240 * spamming the system log on device probing and do nothing here.
241 */
242 242
243 /* Check success of the i2c operation */ 243 /* Check success of the i2c operation */
244 ret = dev->em28xx_read_reg(dev, 0x05); 244 ret = dev->em28xx_read_reg(dev, 0x05);