Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 192679
b: refs/heads/master
c: cf9e150
h: refs/heads/master
i:
  192677: 568e1e1
  192675: 1349787
  192671: 9c4c949
v: v3
  • Loading branch information
Christopher Pascoe authored and Mauro Carvalho Chehab committed May 18, 2010
1 parent 8006b1c commit 38e39e6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3716ae3ed7e4fc0a60c8733f7e6a15ba48f65b01
refs/heads/master: cf9e1509c278c3d5005f222539813933e4dc345c
33 changes: 26 additions & 7 deletions trunk/drivers/staging/tm6000/tm6000-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static int tm6000_i2c_xfer(struct i2c_adapter *i2c_adap,
{
struct tm6000_core *dev = i2c_adap->algo_data;
int addr, rc, i, byte;
u8 prev_reg = 0;
int prev_reg = -1;

if (num <= 0)
return 0;
Expand All @@ -113,16 +113,38 @@ static int tm6000_i2c_xfer(struct i2c_adapter *i2c_adap,
out of message data.
*/
/* SMBus Read Byte command */
if (prev_reg < 0)
printk("XXX read from unknown prev_reg\n");
rc = tm6000_read_write_usb (dev,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
REQ_16_SET_GET_I2CSEQ,
addr | (prev_reg << 8), 0,
msgs[i].buf, msgs[i].len);
if (prev_reg >= 0)
prev_reg += msgs[i].len;
if (i2c_debug>=2) {
for (byte = 0; byte < msgs[i].len; byte++) {
printk(" %02x", msgs[i].buf[byte]);
}
}
} else if (i+1 < num && msgs[i].len == 2 &&
(msgs[i+1].flags & I2C_M_RD) &&
msgs[i].addr == msgs[i+1].addr) {
i2c_dprintk(2, "msg %d: write 2, read %d", i,
msgs[i+1].len);
/* Write 2 Read N command */
rc = tm6000_read_write_usb (dev,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
REQ_14_SET_GET_EEPROM_PAGE, /* XXX wrong name */
addr | msgs[i].buf[0] << 8, msgs[i].buf[1],
msgs[i+1].buf, msgs[i+1].len);
i++;
if (i2c_debug>=2) {
for (byte = 0; byte < msgs[i].len; byte++) {
printk(" %02x", msgs[i].buf[byte]);
}
}
prev_reg = -1;
} else {
/* write bytes */
if (i2c_debug>=2) {
Expand All @@ -134,6 +156,8 @@ static int tm6000_i2c_xfer(struct i2c_adapter *i2c_adap,
if(msgs[i].len == 1 && i+1 < num && msgs[i+1].flags & I2C_M_RD
&& msgs[i+1].addr == msgs[i].addr) {
prev_reg = msgs[i].buf[0];
if (i2c_debug >= 2)
printk("\n");
continue;
}

Expand All @@ -143,12 +167,7 @@ static int tm6000_i2c_xfer(struct i2c_adapter *i2c_adap,
addr|(*msgs[i].buf)<<8, 0,
msgs[i].buf+1, msgs[i].len-1);

if(msgs[i].len >= 1) {
prev_reg = msgs[i].buf[0];
}
else {
prev_reg = 0;
}
prev_reg = -1;
}
if (i2c_debug>=2)
printk("\n");
Expand Down

0 comments on commit 38e39e6

Please sign in to comment.