diff options
Diffstat (limited to 'drivers/media/usb/em28xx/em28xx-i2c.c')
| -rw-r--r-- | drivers/media/usb/em28xx/em28xx-i2c.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c index 342f35ad6070..76f956635bd9 100644 --- a/drivers/media/usb/em28xx/em28xx-i2c.c +++ b/drivers/media/usb/em28xx/em28xx-i2c.c | |||
| @@ -80,7 +80,7 @@ static int em2800_i2c_send_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len) | |||
| 80 | if (ret == 0x80 + len - 1) | 80 | if (ret == 0x80 + len - 1) |
| 81 | return len; | 81 | return len; |
| 82 | if (ret == 0x94 + len - 1) { | 82 | if (ret == 0x94 + len - 1) { |
| 83 | return -ENODEV; | 83 | return -ENXIO; |
| 84 | } | 84 | } |
| 85 | if (ret < 0) { | 85 | if (ret < 0) { |
| 86 | em28xx_warn("failed to get i2c transfer status from bridge register (error=%i)\n", | 86 | em28xx_warn("failed to get i2c transfer status from bridge register (error=%i)\n", |
| @@ -90,7 +90,7 @@ static int em2800_i2c_send_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len) | |||
| 90 | msleep(5); | 90 | msleep(5); |
| 91 | } | 91 | } |
| 92 | em28xx_warn("write to i2c device at 0x%x timed out\n", addr); | 92 | em28xx_warn("write to i2c device at 0x%x timed out\n", addr); |
| 93 | return -EIO; | 93 | return -ETIMEDOUT; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | /* | 96 | /* |
| @@ -123,7 +123,7 @@ static int em2800_i2c_recv_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len) | |||
| 123 | if (ret == 0x84 + len - 1) | 123 | if (ret == 0x84 + len - 1) |
| 124 | break; | 124 | break; |
| 125 | if (ret == 0x94 + len - 1) { | 125 | if (ret == 0x94 + len - 1) { |
| 126 | return -ENODEV; | 126 | return -ENXIO; |
| 127 | } | 127 | } |
| 128 | if (ret < 0) { | 128 | if (ret < 0) { |
| 129 | em28xx_warn("failed to get i2c transfer status from bridge register (error=%i)\n", | 129 | em28xx_warn("failed to get i2c transfer status from bridge register (error=%i)\n", |
| @@ -199,7 +199,7 @@ static int em28xx_i2c_send_bytes(struct em28xx *dev, u16 addr, u8 *buf, | |||
| 199 | if (ret == 0) /* success */ | 199 | if (ret == 0) /* success */ |
| 200 | return len; | 200 | return len; |
| 201 | if (ret == 0x10) { | 201 | if (ret == 0x10) { |
| 202 | return -ENODEV; | 202 | return -ENXIO; |
| 203 | } | 203 | } |
| 204 | if (ret < 0) { | 204 | if (ret < 0) { |
| 205 | em28xx_warn("failed to get i2c transfer status from bridge register (error=%i)\n", | 205 | em28xx_warn("failed to get i2c transfer status from bridge register (error=%i)\n", |
| @@ -213,9 +213,8 @@ static int em28xx_i2c_send_bytes(struct em28xx *dev, u16 addr, u8 *buf, | |||
| 213 | * (even with high payload) ... | 213 | * (even with high payload) ... |
| 214 | */ | 214 | */ |
| 215 | } | 215 | } |
| 216 | 216 | em28xx_warn("write to i2c device at 0x%x timed out (status=%i)\n", addr, ret); | |
| 217 | em28xx_warn("write to i2c device at 0x%x timed out\n", addr); | 217 | return -ETIMEDOUT; |
| 218 | return -EIO; | ||
| 219 | } | 218 | } |
| 220 | 219 | ||
| 221 | /* | 220 | /* |
| @@ -245,7 +244,7 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len) | |||
| 245 | * bytes if we are on bus B AND there was no write attempt to the | 244 | * bytes if we are on bus B AND there was no write attempt to the |
| 246 | * specified slave address before AND no device is present at the | 245 | * specified slave address before AND no device is present at the |
| 247 | * requested slave address. | 246 | * requested slave address. |
| 248 | * Anyway, the next check will fail with -ENODEV in this case, so avoid | 247 | * Anyway, the next check will fail with -ENXIO in this case, so avoid |
| 249 | * spamming the system log on device probing and do nothing here. | 248 | * spamming the system log on device probing and do nothing here. |
| 250 | */ | 249 | */ |
| 251 | 250 | ||
| @@ -259,10 +258,10 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len) | |||
| 259 | return ret; | 258 | return ret; |
| 260 | } | 259 | } |
| 261 | if (ret == 0x10) | 260 | if (ret == 0x10) |
| 262 | return -ENODEV; | 261 | return -ENXIO; |
| 263 | 262 | ||
| 264 | em28xx_warn("unknown i2c error (status=%i)\n", ret); | 263 | em28xx_warn("unknown i2c error (status=%i)\n", ret); |
| 265 | return -EIO; | 264 | return -ETIMEDOUT; |
| 266 | } | 265 | } |
| 267 | 266 | ||
| 268 | /* | 267 | /* |
| @@ -318,7 +317,7 @@ static int em25xx_bus_B_send_bytes(struct em28xx *dev, u16 addr, u8 *buf, | |||
| 318 | if (!ret) | 317 | if (!ret) |
| 319 | return len; | 318 | return len; |
| 320 | else if (ret > 0) | 319 | else if (ret > 0) |
| 321 | return -ENODEV; | 320 | return -ENXIO; |
| 322 | 321 | ||
| 323 | return ret; | 322 | return ret; |
| 324 | /* | 323 | /* |
| @@ -356,7 +355,7 @@ static int em25xx_bus_B_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, | |||
| 356 | * bytes if we are on bus B AND there was no write attempt to the | 355 | * bytes if we are on bus B AND there was no write attempt to the |
| 357 | * specified slave address before AND no device is present at the | 356 | * specified slave address before AND no device is present at the |
| 358 | * requested slave address. | 357 | * requested slave address. |
| 359 | * Anyway, the next check will fail with -ENODEV in this case, so avoid | 358 | * Anyway, the next check will fail with -ENXIO in this case, so avoid |
| 360 | * spamming the system log on device probing and do nothing here. | 359 | * spamming the system log on device probing and do nothing here. |
| 361 | */ | 360 | */ |
| 362 | 361 | ||
| @@ -369,7 +368,7 @@ static int em25xx_bus_B_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, | |||
| 369 | if (!ret) | 368 | if (!ret) |
| 370 | return len; | 369 | return len; |
| 371 | else if (ret > 0) | 370 | else if (ret > 0) |
| 372 | return -ENODEV; | 371 | return -ENXIO; |
| 373 | 372 | ||
| 374 | return ret; | 373 | return ret; |
| 375 | /* | 374 | /* |
| @@ -410,7 +409,7 @@ static inline int i2c_check_for_device(struct em28xx_i2c_bus *i2c_bus, u16 addr) | |||
| 410 | rc = em2800_i2c_check_for_device(dev, addr); | 409 | rc = em2800_i2c_check_for_device(dev, addr); |
| 411 | else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM25XX_BUS_B) | 410 | else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM25XX_BUS_B) |
| 412 | rc = em25xx_bus_B_check_for_device(dev, addr); | 411 | rc = em25xx_bus_B_check_for_device(dev, addr); |
| 413 | if (rc == -ENODEV) { | 412 | if (rc == -ENXIO) { |
| 414 | if (i2c_debug) | 413 | if (i2c_debug) |
| 415 | printk(" no device\n"); | 414 | printk(" no device\n"); |
| 416 | } | 415 | } |
| @@ -498,11 +497,15 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap, | |||
| 498 | (msgs[i].flags & I2C_M_RD) ? "read" : "write", | 497 | (msgs[i].flags & I2C_M_RD) ? "read" : "write", |
| 499 | i == num - 1 ? "stop" : "nonstop", | 498 | i == num - 1 ? "stop" : "nonstop", |
| 500 | addr, msgs[i].len); | 499 | addr, msgs[i].len); |
| 501 | if (!msgs[i].len) { /* no len: check only for device presence */ | 500 | if (!msgs[i].len) { |
| 501 | /* | ||
| 502 | * no len: check only for device presence | ||
| 503 | * This code is only called during device probe. | ||
| 504 | */ | ||
| 502 | rc = i2c_check_for_device(i2c_bus, addr); | 505 | rc = i2c_check_for_device(i2c_bus, addr); |
| 503 | if (rc == -ENODEV) { | 506 | if (rc == -ENXIO) { |
| 504 | rt_mutex_unlock(&dev->i2c_bus_lock); | 507 | rt_mutex_unlock(&dev->i2c_bus_lock); |
| 505 | return rc; | 508 | return -ENODEV; |
| 506 | } | 509 | } |
| 507 | } else if (msgs[i].flags & I2C_M_RD) { | 510 | } else if (msgs[i].flags & I2C_M_RD) { |
| 508 | /* read bytes */ | 511 | /* read bytes */ |
