V4L/DVB: cx23885: Check for slave nack on all transactions
authorJean Delvare <khali@linux-fr.org>
Sun, 18 Jul 2010 19:52:05 +0000 (16:52 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 9 Aug 2010 02:42:53 +0000 (23:42 -0300)
Don't just check for nacks on zero-length transactions. Check on
other transactions too.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andy Walls <awalls@md.metrocast.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/cx23885/cx23885-i2c.c

index 154c914ae16fe29197503c9fe00787dd589fab31..afb8d6f91d1428e509c7a9cfda2675c07a467c48 100644 (file)
@@ -125,6 +125,10 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap,
                goto err;
        if (retval == 0)
                goto eio;
+       if (!i2c_slave_did_ack(i2c_adap)) {
+               retval = -ENXIO;
+               goto err;
+       }
        if (i2c_debug) {
                printk(" <W %02x %02x", msg->addr << 1, msg->buf[0]);
                if (!(ctrl & I2C_NOSTOP))
@@ -214,6 +218,10 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap,
                        goto err;
                if (retval == 0)
                        goto eio;
+               if (cnt == 0 && !i2c_slave_did_ack(i2c_adap)) {
+                       retval = -ENXIO;
+                       goto err;
+               }
                msg->buf[cnt] = cx_read(bus->reg_rdata) & 0xff;
                if (i2c_debug) {
                        dprintk(1, " %02x", msg->buf[cnt]);