diff options
Diffstat (limited to 'drivers/media/video/cx23885/cx23885-i2c.c')
-rw-r--r-- | drivers/media/video/cx23885/cx23885-i2c.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/media/video/cx23885/cx23885-i2c.c b/drivers/media/video/cx23885/cx23885-i2c.c index d4746e064516..1a391486e551 100644 --- a/drivers/media/video/cx23885/cx23885-i2c.c +++ b/drivers/media/video/cx23885/cx23885-i2c.c | |||
@@ -99,7 +99,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, | |||
99 | if (!i2c_wait_done(i2c_adap)) | 99 | if (!i2c_wait_done(i2c_adap)) |
100 | return -EIO; | 100 | return -EIO; |
101 | if (!i2c_slave_did_ack(i2c_adap)) | 101 | if (!i2c_slave_did_ack(i2c_adap)) |
102 | return -EIO; | 102 | return -ENXIO; |
103 | 103 | ||
104 | dprintk(1, "%s() returns 0\n", __func__); | 104 | dprintk(1, "%s() returns 0\n", __func__); |
105 | return 0; | 105 | return 0; |
@@ -120,11 +120,12 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, | |||
120 | cx_write(bus->reg_wdata, wdata); | 120 | cx_write(bus->reg_wdata, wdata); |
121 | cx_write(bus->reg_ctrl, ctrl); | 121 | cx_write(bus->reg_ctrl, ctrl); |
122 | 122 | ||
123 | retval = i2c_wait_done(i2c_adap); | 123 | if (!i2c_wait_done(i2c_adap)) |
124 | if (retval < 0) | ||
125 | goto err; | ||
126 | if (retval == 0) | ||
127 | goto eio; | 124 | goto eio; |
125 | if (!i2c_slave_did_ack(i2c_adap)) { | ||
126 | retval = -ENXIO; | ||
127 | goto err; | ||
128 | } | ||
128 | if (i2c_debug) { | 129 | if (i2c_debug) { |
129 | printk(" <W %02x %02x", msg->addr << 1, msg->buf[0]); | 130 | printk(" <W %02x %02x", msg->addr << 1, msg->buf[0]); |
130 | if (!(ctrl & I2C_NOSTOP)) | 131 | if (!(ctrl & I2C_NOSTOP)) |
@@ -145,10 +146,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, | |||
145 | cx_write(bus->reg_wdata, wdata); | 146 | cx_write(bus->reg_wdata, wdata); |
146 | cx_write(bus->reg_ctrl, ctrl); | 147 | cx_write(bus->reg_ctrl, ctrl); |
147 | 148 | ||
148 | retval = i2c_wait_done(i2c_adap); | 149 | if (!i2c_wait_done(i2c_adap)) |
149 | if (retval < 0) | ||
150 | goto err; | ||
151 | if (retval == 0) | ||
152 | goto eio; | 150 | goto eio; |
153 | if (i2c_debug) { | 151 | if (i2c_debug) { |
154 | dprintk(1, " %02x", msg->buf[cnt]); | 152 | dprintk(1, " %02x", msg->buf[cnt]); |
@@ -185,7 +183,7 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap, | |||
185 | if (!i2c_wait_done(i2c_adap)) | 183 | if (!i2c_wait_done(i2c_adap)) |
186 | return -EIO; | 184 | return -EIO; |
187 | if (!i2c_slave_did_ack(i2c_adap)) | 185 | if (!i2c_slave_did_ack(i2c_adap)) |
188 | return -EIO; | 186 | return -ENXIO; |
189 | 187 | ||
190 | 188 | ||
191 | dprintk(1, "%s() returns 0\n", __func__); | 189 | dprintk(1, "%s() returns 0\n", __func__); |
@@ -209,11 +207,12 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap, | |||
209 | cx_write(bus->reg_addr, msg->addr << 25); | 207 | cx_write(bus->reg_addr, msg->addr << 25); |
210 | cx_write(bus->reg_ctrl, ctrl); | 208 | cx_write(bus->reg_ctrl, ctrl); |
211 | 209 | ||
212 | retval = i2c_wait_done(i2c_adap); | 210 | if (!i2c_wait_done(i2c_adap)) |
213 | if (retval < 0) | ||
214 | goto err; | ||
215 | if (retval == 0) | ||
216 | goto eio; | 211 | goto eio; |
212 | if (cnt == 0 && !i2c_slave_did_ack(i2c_adap)) { | ||
213 | retval = -ENXIO; | ||
214 | goto err; | ||
215 | } | ||
217 | msg->buf[cnt] = cx_read(bus->reg_rdata) & 0xff; | 216 | msg->buf[cnt] = cx_read(bus->reg_rdata) & 0xff; |
218 | if (i2c_debug) { | 217 | if (i2c_debug) { |
219 | dprintk(1, " %02x", msg->buf[cnt]); | 218 | dprintk(1, " %02x", msg->buf[cnt]); |