V4L/DVB (6404): cx23885: i2c 16bit reg/val read/write fix

Fix i2c reads and writes of 16bit register address / values

Signed-off-by: Steven Toth <stoth@hauppauge.com>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This commit is contained in:
Steven Toth 2007-09-20 01:44:27 -03:00 committed by Mauro Carvalho Chehab
parent 289d4d2f07
commit e92adc2c39

View File

@ -84,7 +84,8 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap,
u32 wdata, addr, ctrl; u32 wdata, addr, ctrl;
int retval, cnt; int retval, cnt;
dprintk(1, "%s()\n", __FUNCTION__); dprintk(1, "%s(msg->len=%d, last=%d)\n", __FUNCTION__, msg->len, last);
/* Deal with i2c probe functions with zero payload */ /* Deal with i2c probe functions with zero payload */
if (msg->len == 0) { if (msg->len == 0) {
cx_write(bus->reg_addr, msg->addr << 25); cx_write(bus->reg_addr, msg->addr << 25);
@ -127,7 +128,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap,
wdata = msg->buf[cnt]; wdata = msg->buf[cnt];
ctrl = bus->i2c_period | (1 << 12) | (1 << 2); ctrl = bus->i2c_period | (1 << 12) | (1 << 2);
if (cnt < msg->len-1 || !last) if (cnt < msg->len - 1)
ctrl |= I2C_NOSTOP | I2C_EXTEND; ctrl |= I2C_NOSTOP | I2C_EXTEND;
cx_write(bus->reg_addr, addr); cx_write(bus->reg_addr, addr);
@ -162,7 +163,7 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap,
u32 ctrl, cnt; u32 ctrl, cnt;
int retval; int retval;
dprintk(1, "%s()\n", __FUNCTION__); dprintk(1, "%s(msg->len=%d, last=%d)\n", __FUNCTION__, msg->len, last);
/* Deal with i2c probe functions with zero payload */ /* Deal with i2c probe functions with zero payload */
if (msg->len == 0) { if (msg->len == 0) {
@ -178,11 +179,14 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap,
return 0; return 0;
} }
if (i2c_debug)
printk(" <R %02x", (msg->addr << 1) + 1);
for(cnt = 0; cnt < msg->len; cnt++) { for(cnt = 0; cnt < msg->len; cnt++) {
ctrl = bus->i2c_period | (1 << 12) | (1 << 2) | 1; ctrl = bus->i2c_period | (1 << 12) | (1 << 2) | 1;
if (cnt < msg->len-1 || !last) if (cnt < msg->len - 1)
ctrl |= I2C_NOSTOP | I2C_EXTEND; ctrl |= I2C_NOSTOP | I2C_EXTEND;
cx_write(bus->reg_addr, msg->addr << 25); cx_write(bus->reg_addr, msg->addr << 25);
@ -195,9 +199,7 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap,
goto eio; goto eio;
msg->buf[cnt] = cx_read(bus->reg_rdata) & 0xff; msg->buf[cnt] = cx_read(bus->reg_rdata) & 0xff;
if (i2c_debug) { if (i2c_debug) {
if (!(ctrl & I2C_NOSTOP)) printk(" %02x", msg->buf[cnt]);
printk(" <R %02x", (msg->addr << 1) +1);
printk(" =%02x", msg->buf[cnt]);
if (!(ctrl & I2C_NOSTOP)) if (!(ctrl & I2C_NOSTOP))
printk(" >\n"); printk(" >\n");
} }