Commit 494dbb64 authored by Jean Delvare's avatar Jean Delvare Committed by Jean Delvare

i2c-algo-bit: Improve debugging

Improve the debugging features of the i2c-algo-bit driver:
* Make it possible to compile the driver without debugging support
  at all, making it much smaller.
* Use dev_dbg() for debugging messages where possible, and dev_err()
  for error messages.
* Remove redundant debugging messages.

These changes allowed for minor code cleanups, which are included
as well.
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent 424ed67c
...@@ -33,19 +33,30 @@ ...@@ -33,19 +33,30 @@
/* ----- global defines ----------------------------------------------- */ /* ----- global defines ----------------------------------------------- */
#define DEB(x) if (i2c_debug>=1) x;
#define DEB2(x) if (i2c_debug>=2) x;
#define DEBSTAT(x) if (i2c_debug>=3) x; /* print several statistical values*/
#define DEBPROTO(x) if (i2c_debug>=9) { x; }
/* debug the protocol by showing transferred bits */
#ifdef DEBUG
#define bit_dbg(level, dev, format, args...) \
do { \
if (i2c_debug >= level) \
dev_dbg(dev, format, ##args); \
} while (0)
#else
#define bit_dbg(level, dev, format, args...) \
do {} while (0)
#endif /* DEBUG */
/* ----- global variables --------------------------------------------- */ /* ----- global variables --------------------------------------------- */
/* module parameters:
*/
static int i2c_debug;
static int bit_test; /* see if the line-setting functions work */ static int bit_test; /* see if the line-setting functions work */
module_param(bit_test, bool, 0);
MODULE_PARM_DESC(bit_test, "Test the lines of the bus to see if it is stuck");
#ifdef DEBUG
static int i2c_debug = 1;
module_param(i2c_debug, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(i2c_debug,
"debug level - 0 off; 1 normal; 2 verbose; 3 very verbose");
#endif
/* --- setting states on the bus with the right timing: --------------- */ /* --- setting states on the bus with the right timing: --------------- */
...@@ -98,7 +109,11 @@ static int sclhi(struct i2c_algo_bit_data *adap) ...@@ -98,7 +109,11 @@ static int sclhi(struct i2c_algo_bit_data *adap)
} }
cond_resched(); cond_resched();
} }
DEBSTAT(printk(KERN_DEBUG "needed %ld jiffies\n", jiffies-start)); #ifdef DEBUG
if (jiffies != start && i2c_debug >= 3)
pr_debug("i2c-algo-bit: needed %ld jiffies for SCL to go "
"high\n", jiffies - start);
#endif
done: done:
udelay(adap->udelay); udelay(adap->udelay);
...@@ -110,7 +125,6 @@ static int sclhi(struct i2c_algo_bit_data *adap) ...@@ -110,7 +125,6 @@ static int sclhi(struct i2c_algo_bit_data *adap)
static void i2c_start(struct i2c_algo_bit_data *adap) static void i2c_start(struct i2c_algo_bit_data *adap)
{ {
/* assert: scl, sda are high */ /* assert: scl, sda are high */
DEBPROTO(printk("S "));
setsda(adap, 0); setsda(adap, 0);
udelay(adap->udelay); udelay(adap->udelay);
scllo(adap); scllo(adap);
...@@ -119,7 +133,6 @@ static void i2c_start(struct i2c_algo_bit_data *adap) ...@@ -119,7 +133,6 @@ static void i2c_start(struct i2c_algo_bit_data *adap)
static void i2c_repstart(struct i2c_algo_bit_data *adap) static void i2c_repstart(struct i2c_algo_bit_data *adap)
{ {
/* assert: scl is low */ /* assert: scl is low */
DEBPROTO(printk(" Sr "));
sdahi(adap); sdahi(adap);
sclhi(adap); sclhi(adap);
setsda(adap, 0); setsda(adap, 0);
...@@ -130,7 +143,6 @@ static void i2c_repstart(struct i2c_algo_bit_data *adap) ...@@ -130,7 +143,6 @@ static void i2c_repstart(struct i2c_algo_bit_data *adap)
static void i2c_stop(struct i2c_algo_bit_data *adap) static void i2c_stop(struct i2c_algo_bit_data *adap)
{ {
DEBPROTO(printk("P\n"));
/* assert: scl is low */ /* assert: scl is low */
sdalo(adap); sdalo(adap);
sclhi(adap); sclhi(adap);
...@@ -147,7 +159,7 @@ static void i2c_stop(struct i2c_algo_bit_data *adap) ...@@ -147,7 +159,7 @@ static void i2c_stop(struct i2c_algo_bit_data *adap)
* 0 if the device did not ack * 0 if the device did not ack
* -ETIMEDOUT if an error occurred (while raising the scl line) * -ETIMEDOUT if an error occurred (while raising the scl line)
*/ */
static int i2c_outb(struct i2c_adapter *i2c_adap, char c) static int i2c_outb(struct i2c_adapter *i2c_adap, unsigned char c)
{ {
int i; int i;
int sb; int sb;
...@@ -156,12 +168,12 @@ static int i2c_outb(struct i2c_adapter *i2c_adap, char c) ...@@ -156,12 +168,12 @@ static int i2c_outb(struct i2c_adapter *i2c_adap, char c)
/* assert: scl is low */ /* assert: scl is low */
for ( i=7 ; i>=0 ; i-- ) { for ( i=7 ; i>=0 ; i-- ) {
sb = c & ( 1 << i ); sb = (c >> i) & 1;
setsda(adap,sb); setsda(adap,sb);
udelay((adap->udelay + 1) / 2); udelay((adap->udelay + 1) / 2);
DEBPROTO(printk(KERN_DEBUG "%d",sb!=0));
if (sclhi(adap)<0) { /* timed out */ if (sclhi(adap)<0) { /* timed out */
DEB2(printk(KERN_DEBUG " i2c_outb: 0x%02x, timeout at bit #%d\n", c&0xff, i)); bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, "
"timeout at bit #%d\n", (int)c, i);
return -ETIMEDOUT; return -ETIMEDOUT;
}; };
/* do arbitration here: /* do arbitration here:
...@@ -171,17 +183,17 @@ static int i2c_outb(struct i2c_adapter *i2c_adap, char c) ...@@ -171,17 +183,17 @@ static int i2c_outb(struct i2c_adapter *i2c_adap, char c)
} }
sdahi(adap); sdahi(adap);
if (sclhi(adap)<0){ /* timeout */ if (sclhi(adap)<0){ /* timeout */
DEB2(printk(KERN_DEBUG " i2c_outb: 0x%02x, timeout at ack\n", c&0xff)); bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, "
return -ETIMEDOUT; "timeout at ack\n", (int)c);
return -ETIMEDOUT;
}; };
/* read ack: SDA should be pulled down by slave */ /* read ack: SDA should be pulled down by slave */
ack=getsda(adap); /* ack: sda is pulled low ->success. */ ack = !getsda(adap); /* ack: sda is pulled low -> success */
DEB2(printk(KERN_DEBUG " i2c_outb: 0x%02x , getsda() = %d\n", c & 0xff, ack)); bit_dbg(2, &i2c_adap->dev, "i2c_outb: 0x%02x %s\n", (int)c,
ack ? "A" : "NA");
DEBPROTO( printk(KERN_DEBUG "[%2.2x]",c&0xff) );
DEBPROTO(if (0==ack){ printk(KERN_DEBUG " A ");} else printk(KERN_DEBUG " NA ") );
scllo(adap); scllo(adap);
return 0==ack; /* return 1 if device acked */ return ack;
/* assert: scl is low (sda undef) */ /* assert: scl is low (sda undef) */
} }
...@@ -198,7 +210,8 @@ static int i2c_inb(struct i2c_adapter *i2c_adap) ...@@ -198,7 +210,8 @@ static int i2c_inb(struct i2c_adapter *i2c_adap)
sdahi(adap); sdahi(adap);
for (i=0;i<8;i++) { for (i=0;i<8;i++) {
if (sclhi(adap)<0) { /* timeout */ if (sclhi(adap)<0) { /* timeout */
DEB2(printk(KERN_DEBUG " i2c_inb: timeout at bit #%d\n", 7-i)); bit_dbg(1, &i2c_adap->dev, "i2c_inb: timeout at bit "
"#%d\n", 7 - i);
return -ETIMEDOUT; return -ETIMEDOUT;
}; };
indata *= 2; indata *= 2;
...@@ -208,10 +221,7 @@ static int i2c_inb(struct i2c_adapter *i2c_adap) ...@@ -208,10 +221,7 @@ static int i2c_inb(struct i2c_adapter *i2c_adap)
udelay(i == 7 ? adap->udelay / 2 : adap->udelay); udelay(i == 7 ? adap->udelay / 2 : adap->udelay);
} }
/* assert: scl is low */ /* assert: scl is low */
DEB2(printk(KERN_DEBUG "i2c_inb: 0x%02x\n", indata & 0xff)); return indata;
DEBPROTO(printk(KERN_DEBUG " 0x%02x", indata & 0xff));
return (int) (indata & 0xff);
} }
/* /*
...@@ -222,73 +232,67 @@ static int test_bus(struct i2c_algo_bit_data *adap, char* name) { ...@@ -222,73 +232,67 @@ static int test_bus(struct i2c_algo_bit_data *adap, char* name) {
int scl,sda; int scl,sda;
if (adap->getscl==NULL) if (adap->getscl==NULL)
printk(KERN_INFO "i2c-algo-bit.o: Testing SDA only, " pr_info("%s: Testing SDA only, SCL is not readable\n", name);
"SCL is not readable.\n");
sda=getsda(adap); sda=getsda(adap);
scl=(adap->getscl==NULL?1:getscl(adap)); scl=(adap->getscl==NULL?1:getscl(adap));
printk(KERN_DEBUG "i2c-algo-bit.o: (0) scl=%d, sda=%d\n",scl,sda);
if (!scl || !sda ) { if (!scl || !sda ) {
printk(KERN_WARNING "i2c-algo-bit.o: %s seems to be busy.\n", name); printk(KERN_WARNING "%s: bus seems to be busy\n", name);
goto bailout; goto bailout;
} }
sdalo(adap); sdalo(adap);
sda=getsda(adap); sda=getsda(adap);
scl=(adap->getscl==NULL?1:getscl(adap)); scl=(adap->getscl==NULL?1:getscl(adap));
printk(KERN_DEBUG "i2c-algo-bit.o: (1) scl=%d, sda=%d\n",scl,sda);
if ( 0 != sda ) { if ( 0 != sda ) {
printk(KERN_WARNING "i2c-algo-bit.o: SDA stuck high!\n"); printk(KERN_WARNING "%s: SDA stuck high!\n", name);
goto bailout; goto bailout;
} }
if ( 0 == scl ) { if ( 0 == scl ) {
printk(KERN_WARNING "i2c-algo-bit.o: SCL unexpected low " printk(KERN_WARNING "%s: SCL unexpected low "
"while pulling SDA low!\n"); "while pulling SDA low!\n", name);
goto bailout; goto bailout;
} }
sdahi(adap); sdahi(adap);
sda=getsda(adap); sda=getsda(adap);
scl=(adap->getscl==NULL?1:getscl(adap)); scl=(adap->getscl==NULL?1:getscl(adap));
printk(KERN_DEBUG "i2c-algo-bit.o: (2) scl=%d, sda=%d\n",scl,sda);
if ( 0 == sda ) { if ( 0 == sda ) {
printk(KERN_WARNING "i2c-algo-bit.o: SDA stuck low!\n"); printk(KERN_WARNING "%s: SDA stuck low!\n", name);
goto bailout; goto bailout;
} }
if ( 0 == scl ) { if ( 0 == scl ) {
printk(KERN_WARNING "i2c-algo-bit.o: SCL unexpected low " printk(KERN_WARNING "%s: SCL unexpected low "
"while pulling SDA high!\n"); "while pulling SDA high!\n", name);
goto bailout; goto bailout;
} }
scllo(adap); scllo(adap);
sda=getsda(adap); sda=getsda(adap);
scl=(adap->getscl==NULL?0:getscl(adap)); scl=(adap->getscl==NULL?0:getscl(adap));
printk(KERN_DEBUG "i2c-algo-bit.o: (3) scl=%d, sda=%d\n",scl,sda);
if ( 0 != scl ) { if ( 0 != scl ) {
printk(KERN_WARNING "i2c-algo-bit.o: SCL stuck high!\n"); printk(KERN_WARNING "%s: SCL stuck high!\n", name);
goto bailout; goto bailout;
} }
if ( 0 == sda ) { if ( 0 == sda ) {
printk(KERN_WARNING "i2c-algo-bit.o: SDA unexpected low " printk(KERN_WARNING "%s: SDA unexpected low "
"while pulling SCL low!\n"); "while pulling SCL low!\n", name);
goto bailout; goto bailout;
} }
sclhi(adap); sclhi(adap);
sda=getsda(adap); sda=getsda(adap);
scl=(adap->getscl==NULL?1:getscl(adap)); scl=(adap->getscl==NULL?1:getscl(adap));
printk(KERN_DEBUG "i2c-algo-bit.o: (4) scl=%d, sda=%d\n",scl,sda);
if ( 0 == scl ) { if ( 0 == scl ) {
printk(KERN_WARNING "i2c-algo-bit.o: SCL stuck low!\n"); printk(KERN_WARNING "%s: SCL stuck low!\n", name);
goto bailout; goto bailout;
} }
if ( 0 == sda ) { if ( 0 == sda ) {
printk(KERN_WARNING "i2c-algo-bit.o: SDA unexpected low " printk(KERN_WARNING "%s: SDA unexpected low "
"while pulling SCL high!\n"); "while pulling SCL high!\n", name);
goto bailout; goto bailout;
} }
printk(KERN_INFO "i2c-algo-bit.o: %s passed test.\n",name); pr_info("%s: Test OK\n", name);
return 0; return 0;
bailout: bailout:
sdahi(adap); sdahi(adap);
...@@ -315,32 +319,31 @@ static int try_address(struct i2c_adapter *i2c_adap, ...@@ -315,32 +319,31 @@ static int try_address(struct i2c_adapter *i2c_adap,
ret = i2c_outb(i2c_adap,addr); ret = i2c_outb(i2c_adap,addr);
if (ret == 1 || i == retries) if (ret == 1 || i == retries)
break; break;
bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n");
i2c_stop(adap); i2c_stop(adap);
udelay(adap->udelay); udelay(adap->udelay);
yield(); yield();
bit_dbg(3, &i2c_adap->dev, "emitting start condition\n");
i2c_start(adap); i2c_start(adap);
} }
DEB2(if (i) if (i && ret)
printk(KERN_DEBUG "i2c-algo-bit.o: Used %d tries to %s client at 0x%02x : %s\n", bit_dbg(1, &i2c_adap->dev, "Used %d tries to %s client at "
i+1, addr & 1 ? "read" : "write", addr>>1, "0x%02x: %s\n", i + 1,
ret==1 ? "success" : ret==0 ? "no ack" : "failed, timeout?" ) addr & 1 ? "read from" : "write to", addr >> 1,
); ret == 1 ? "success" : "failed, timeout?");
return ret; return ret;
} }
static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
{ {
char c; const unsigned char *temp = msg->buf;
const char *temp = msg->buf;
int count = msg->len; int count = msg->len;
unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK; unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK;
int retval; int retval;
int wrcount=0; int wrcount=0;
while (count > 0) { while (count > 0) {
c = *temp; retval = i2c_outb(i2c_adap, *temp);
DEB2(dev_dbg(&i2c_adap->dev, "sendbytes: writing %2.2X\n", c&0xff));
retval = i2c_outb(i2c_adap,c);
if ((retval>0) || (nak_ok && (retval==0))) { /* ok or ignored NAK */ if ((retval>0) || (nak_ok && (retval==0))) { /* ok or ignored NAK */
count--; count--;
temp++; temp++;
...@@ -359,7 +362,7 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) ...@@ -359,7 +362,7 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
int inval; int inval;
int rdcount=0; /* counts bytes read */ int rdcount=0; /* counts bytes read */
struct i2c_algo_bit_data *adap = i2c_adap->algo_data; struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
char *temp = msg->buf; unsigned char *temp = msg->buf;
int count = msg->len; int count = msg->len;
while (count > 0) { while (count > 0) {
...@@ -368,28 +371,26 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) ...@@ -368,28 +371,26 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
*temp = inval; *temp = inval;
rdcount++; rdcount++;
} else { /* read timed out */ } else { /* read timed out */
printk(KERN_ERR "i2c-algo-bit.o: readbytes: i2c_inb timed out.\n");
break; break;
} }
temp++; temp++;
count--; count--;
if (msg->flags & I2C_M_NO_RD_ACK) if (msg->flags & I2C_M_NO_RD_ACK) {
bit_dbg(2, &i2c_adap->dev, "i2c_inb: 0x%02x\n",
inval);
continue; continue;
}
/* assert: sda is high */ /* assert: sda is high */
if ( count > 0 ) { /* send ack */ if (count) /* send ack */
setsda(adap, 0); setsda(adap, 0);
udelay((adap->udelay + 1) / 2); udelay((adap->udelay + 1) / 2);
DEBPROTO(printk(" Am ")); bit_dbg(2, &i2c_adap->dev, "i2c_inb: 0x%02x %s\n", inval,
} else { count ? "A" : "NA");
/* neg. ack on last byte */
udelay((adap->udelay + 1) / 2);
DEBPROTO(printk(" NAm "));
}
if (sclhi(adap)<0) { /* timeout */ if (sclhi(adap)<0) { /* timeout */
printk(KERN_ERR "i2c-algo-bit.o: readbytes: Timeout at ack\n"); dev_err(&i2c_adap->dev, "readbytes: timeout at ack\n");
return -ETIMEDOUT; return -ETIMEDOUT;
}; };
scllo(adap); scllo(adap);
...@@ -398,8 +399,8 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) ...@@ -398,8 +399,8 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
transaction length as the first read byte. */ transaction length as the first read byte. */
if (rdcount == 1 && (msg->flags & I2C_M_RECV_LEN)) { if (rdcount == 1 && (msg->flags & I2C_M_RECV_LEN)) {
if (inval <= 0 || inval > I2C_SMBUS_BLOCK_MAX) { if (inval <= 0 || inval > I2C_SMBUS_BLOCK_MAX) {
printk(KERN_ERR "i2c-algo-bit: readbytes: " dev_err(&i2c_adap->dev, "readbytes: invalid "
"invalid block length (%d)\n", inval); "block length (%d)\n", inval);
return -EREMOTEIO; return -EREMOTEIO;
} }
/* The original count value accounts for the extra /* The original count value accounts for the extra
...@@ -434,27 +435,31 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) ...@@ -434,27 +435,31 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
if ( (flags & I2C_M_TEN) ) { if ( (flags & I2C_M_TEN) ) {
/* a ten bit address */ /* a ten bit address */
addr = 0xf0 | (( msg->addr >> 7) & 0x03); addr = 0xf0 | (( msg->addr >> 7) & 0x03);
DEB2(printk(KERN_DEBUG "addr0: %d\n",addr)); bit_dbg(2, &i2c_adap->dev, "addr0: %d\n", addr);
/* try extended address code...*/ /* try extended address code...*/
ret = try_address(i2c_adap, addr, retries); ret = try_address(i2c_adap, addr, retries);
if ((ret != 1) && !nak_ok) { if ((ret != 1) && !nak_ok) {
printk(KERN_ERR "died at extended address code.\n"); dev_err(&i2c_adap->dev,
"died at extended address code\n");
return -EREMOTEIO; return -EREMOTEIO;
} }
/* the remaining 8 bit address */ /* the remaining 8 bit address */
ret = i2c_outb(i2c_adap,msg->addr & 0x7f); ret = i2c_outb(i2c_adap,msg->addr & 0x7f);
if ((ret != 1) && !nak_ok) { if ((ret != 1) && !nak_ok) {
/* the chip did not ack / xmission error occurred */ /* the chip did not ack / xmission error occurred */
printk(KERN_ERR "died at 2nd address code.\n"); dev_err(&i2c_adap->dev, "died at 2nd address code\n");
return -EREMOTEIO; return -EREMOTEIO;
} }
if ( flags & I2C_M_RD ) { if ( flags & I2C_M_RD ) {
bit_dbg(3, &i2c_adap->dev, "emitting repeated "
"start condition\n");
i2c_repstart(adap); i2c_repstart(adap);
/* okay, now switch into reading mode */ /* okay, now switch into reading mode */
addr |= 0x01; addr |= 0x01;
ret = try_address(i2c_adap, addr, retries); ret = try_address(i2c_adap, addr, retries);
if ((ret!=1) && !nak_ok) { if ((ret!=1) && !nak_ok) {
printk(KERN_ERR "died at extended address code.\n"); dev_err(&i2c_adap->dev,
"died at repeated address code\n");
return -EREMOTEIO; return -EREMOTEIO;
} }
} }
...@@ -481,25 +486,31 @@ static int bit_xfer(struct i2c_adapter *i2c_adap, ...@@ -481,25 +486,31 @@ static int bit_xfer(struct i2c_adapter *i2c_adap,
int i,ret; int i,ret;
unsigned short nak_ok; unsigned short nak_ok;
bit_dbg(3, &i2c_adap->dev, "emitting start condition\n");
i2c_start(adap); i2c_start(adap);
for (i=0;i<num;i++) { for (i=0;i<num;i++) {
pmsg = &msgs[i]; pmsg = &msgs[i];
nak_ok = pmsg->flags & I2C_M_IGNORE_NAK; nak_ok = pmsg->flags & I2C_M_IGNORE_NAK;
if (!(pmsg->flags & I2C_M_NOSTART)) { if (!(pmsg->flags & I2C_M_NOSTART)) {
if (i) { if (i) {
bit_dbg(3, &i2c_adap->dev, "emitting "
"repeated start condition\n");
i2c_repstart(adap); i2c_repstart(adap);
} }
ret = bit_doAddress(i2c_adap, pmsg); ret = bit_doAddress(i2c_adap, pmsg);
if ((ret != 0) && !nak_ok) { if ((ret != 0) && !nak_ok) {
DEB2(printk(KERN_DEBUG "i2c-algo-bit.o: NAK from device addr %2.2x msg #%d\n" bit_dbg(1, &i2c_adap->dev, "NAK from "
,msgs[i].addr,i)); "device addr 0x%02x msg #%d\n",
msgs[i].addr, i);
goto bailout; goto bailout;
} }
} }
if (pmsg->flags & I2C_M_RD ) { if (pmsg->flags & I2C_M_RD ) {
/* read bytes into buffer*/ /* read bytes into buffer*/
ret = readbytes(i2c_adap, pmsg); ret = readbytes(i2c_adap, pmsg);
DEB2(printk(KERN_DEBUG "i2c-algo-bit.o: read %d bytes.\n",ret)); if (ret >= 1)
bit_dbg(2, &i2c_adap->dev, "read %d byte%s\n",
ret, ret == 1 ? "" : "s");
if (ret < pmsg->len) { if (ret < pmsg->len) {
if (ret >= 0) if (ret >= 0)
ret = -EREMOTEIO; ret = -EREMOTEIO;
...@@ -508,7 +519,9 @@ static int bit_xfer(struct i2c_adapter *i2c_adap, ...@@ -508,7 +519,9 @@ static int bit_xfer(struct i2c_adapter *i2c_adap,
} else { } else {
/* write bytes from buffer */ /* write bytes from buffer */
ret = sendbytes(i2c_adap, pmsg); ret = sendbytes(i2c_adap, pmsg);
DEB2(printk(KERN_DEBUG "i2c-algo-bit.o: wrote %d bytes.\n",ret)); if (ret >= 1)
bit_dbg(2, &i2c_adap->dev, "wrote %d byte%s\n",
ret, ret == 1 ? "" : "s");
if (ret < pmsg->len) { if (ret < pmsg->len) {
if (ret >= 0) if (ret >= 0)
ret = -EREMOTEIO; ret = -EREMOTEIO;
...@@ -519,6 +532,7 @@ static int bit_xfer(struct i2c_adapter *i2c_adap, ...@@ -519,6 +532,7 @@ static int bit_xfer(struct i2c_adapter *i2c_adap,
ret = i; ret = i;
bailout: bailout:
bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n");
i2c_stop(adap); i2c_stop(adap);
return ret; return ret;
} }
...@@ -552,8 +566,6 @@ static int i2c_bit_prepare_bus(struct i2c_adapter *adap) ...@@ -552,8 +566,6 @@ static int i2c_bit_prepare_bus(struct i2c_adapter *adap)
return -ENODEV; return -ENODEV;
} }
DEB2(dev_dbg(&adap->dev, "hw routines registered.\n"));
/* register new adapter to i2c module... */ /* register new adapter to i2c module... */
adap->algo = &i2c_bit_algo; adap->algo = &i2c_bit_algo;
...@@ -590,10 +602,3 @@ EXPORT_SYMBOL(i2c_bit_add_numbered_bus); ...@@ -590,10 +602,3 @@ EXPORT_SYMBOL(i2c_bit_add_numbered_bus);
MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm"); MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
module_param(bit_test, bool, 0);
module_param(i2c_debug, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(bit_test, "Test the lines of the bus to see if it is stuck");
MODULE_PARM_DESC(i2c_debug,
"debug level - 0 off; 1 normal; 2,3 more verbose; 9 bit-protocol");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment