From 557d88f94f967486a86e8bc5077e76dd8a87e293 Mon Sep 17 00:00:00 2001 From: Michel Ludwig Date: Fri, 29 Jun 2007 09:51:39 -0300 Subject: [PATCH] --- yaml --- r: 192639 b: refs/heads/master c: 526835d5b30a591578f2813a8837ac70172c0aa9 h: refs/heads/master i: 192637: 75245def36dcab6defa7a97a9c044765735133c1 192635: 305b6df9b30c4331b79d7e9577772f6fa25eaf50 192631: d6b5a2beb9279f3795f426570258f0cdfd4a603e 192623: 3eb5afb3f1702a70811d49e58714275b6a20c910 192607: 5591e9b404a9b11bd962c8a6fac6ec5087327c20 192575: 96846c377105a987b763567e8807e784d6180836 192511: 9325e2bfdab79e49b7c0cb495169b590fb8ee8d3 v: v3 --- [refs] | 2 +- trunk/drivers/staging/tm6000/tm6000-i2c.c | 37 +++++++++++++++++------ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/[refs] b/[refs] index ebb9de04ca4a..bc9b5e396b48 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 0ec4acc6a6405c78a8655687d382ece0daf001b8 +refs/heads/master: 526835d5b30a591578f2813a8837ac70172c0aa9 diff --git a/trunk/drivers/staging/tm6000/tm6000-i2c.c b/trunk/drivers/staging/tm6000/tm6000-i2c.c index 5e165ed25eee..80252b746699 100644 --- a/trunk/drivers/staging/tm6000/tm6000-i2c.c +++ b/trunk/drivers/staging/tm6000/tm6000-i2c.c @@ -3,6 +3,9 @@ Copyright (C) 2006-2007 Mauro Carvalho Chehab + Copyright (C) 2007 Michel Ludwig + - Fix SMBus Read Byte command + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2 @@ -92,6 +95,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; if (num <= 0) return 0; @@ -100,25 +104,31 @@ static int tm6000_i2c_xfer(struct i2c_adapter *i2c_adap, i2c_dprintk(2,"%s %s addr=0x%x len=%d:", (msgs[i].flags & I2C_M_RD) ? "read" : "write", i == num - 1 ? "stop" : "nonstop", addr, msgs[i].len); - if (!msgs[i].len) { /* Do I2C scan */ rc=tm6000_i2c_scan(i2c_adap, addr); } else if (msgs[i].flags & I2C_M_RD) { - char buf[msgs[i].len]; - memcpy(buf,msgs[i].buf, msgs[i].len-1); - buf[msgs[i].len-1]=0; - /* Read bytes */ /* I2C is assumed to have always a subaddr at the first byte of the message bus. Also, the first i2c value of the answer is returned out of message data. */ - rc = tm6000_read_write_usb (dev, - USB_DIR_IN | USB_TYPE_VENDOR, - REQ_16_SET_GET_I2CSEQ, - addr|(*msgs[i].buf)<<8, 0, - msgs[i].buf, msgs[i].len); + /* SMBus Read Byte command */ + if(msgs[i].len == 1) { + // we use the previously used register to read from + 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); + } + else { + rc = tm6000_read_write_usb (dev, + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + REQ_16_SET_GET_I2CSEQ, + addr|(*msgs[i].buf)<<8, 0, + msgs[i].buf, msgs[i].len); + } if (i2c_debug>=2) { for (byte = 0; byte < msgs[i].len; byte++) { printk(" %02x", msgs[i].buf[byte]); @@ -136,6 +146,13 @@ static int tm6000_i2c_xfer(struct i2c_adapter *i2c_adap, REQ_16_SET_GET_I2CSEQ, 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; + } } if (i2c_debug>=2) printk("\n");