Commit 7742cc3e authored by Ian Campbell's avatar Ian Campbell Committed by Greg Kroah-Hartman

[PATCH] I2C: improve debugging output

Rework the pca_xfer() function to always print the number of
successfully completed transfers in a series when debugging, even when
exiting with an error.
Signed-off-by: default avatarIan Campbell <icampbell@arcom.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7f01d23d
...@@ -186,6 +186,7 @@ static int pca_xfer(struct i2c_adapter *i2c_adap, ...@@ -186,6 +186,7 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
int curmsg; int curmsg;
int numbytes = 0; int numbytes = 0;
int state; int state;
int ret;
state = pca_status(adap); state = pca_status(adap);
if ( state != 0xF8 ) { if ( state != 0xF8 ) {
...@@ -218,6 +219,7 @@ static int pca_xfer(struct i2c_adapter *i2c_adap, ...@@ -218,6 +219,7 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
} }
curmsg = 0; curmsg = 0;
ret = -EREMOTEIO;
while (curmsg < num) { while (curmsg < num) {
state = pca_status(adap); state = pca_status(adap);
...@@ -251,7 +253,7 @@ static int pca_xfer(struct i2c_adapter *i2c_adap, ...@@ -251,7 +253,7 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
case 0x20: /* SLA+W has been transmitted; NOT ACK has been received */ case 0x20: /* SLA+W has been transmitted; NOT ACK has been received */
DEB2("NOT ACK received after SLA+W\n"); DEB2("NOT ACK received after SLA+W\n");
pca_stop(adap); pca_stop(adap);
return -EREMOTEIO; goto out;
case 0x40: /* SLA+R has been transmitted; ACK has been received */ case 0x40: /* SLA+R has been transmitted; ACK has been received */
pca_rx_ack(adap, msg->len > 1); pca_rx_ack(adap, msg->len > 1);
...@@ -263,7 +265,7 @@ static int pca_xfer(struct i2c_adapter *i2c_adap, ...@@ -263,7 +265,7 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
numbytes++; numbytes++;
pca_rx_ack(adap, numbytes < msg->len - 1); pca_rx_ack(adap, numbytes < msg->len - 1);
break; break;
} }
curmsg++; numbytes = 0; curmsg++; numbytes = 0;
if (curmsg == num) if (curmsg == num)
pca_stop(adap); pca_stop(adap);
...@@ -274,15 +276,15 @@ static int pca_xfer(struct i2c_adapter *i2c_adap, ...@@ -274,15 +276,15 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
case 0x48: /* SLA+R has been transmitted; NOT ACK has been received */ case 0x48: /* SLA+R has been transmitted; NOT ACK has been received */
DEB2("NOT ACK received after SLA+R\n"); DEB2("NOT ACK received after SLA+R\n");
pca_stop(adap); pca_stop(adap);
return -EREMOTEIO; goto out;
case 0x30: /* Data byte in I2CDAT has been transmitted; NOT ACK has been received */ case 0x30: /* Data byte in I2CDAT has been transmitted; NOT ACK has been received */
DEB2("NOT ACK received after data byte\n"); DEB2("NOT ACK received after data byte\n");
return -EREMOTEIO; goto out;
case 0x38: /* Arbitration lost during SLA+W, SLA+R or data bytes */ case 0x38: /* Arbitration lost during SLA+W, SLA+R or data bytes */
DEB2("Arbitration lost\n"); DEB2("Arbitration lost\n");
return -EREMOTEIO; goto out;
case 0x58: /* Data byte has been received; NOT ACK has been returned */ case 0x58: /* Data byte has been received; NOT ACK has been returned */
if ( numbytes == msg->len - 1 ) { if ( numbytes == msg->len - 1 ) {
...@@ -297,21 +299,21 @@ static int pca_xfer(struct i2c_adapter *i2c_adap, ...@@ -297,21 +299,21 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
"Not final byte. numbytes %d. len %d\n", "Not final byte. numbytes %d. len %d\n",
numbytes, msg->len); numbytes, msg->len);
pca_stop(adap); pca_stop(adap);
return -EREMOTEIO; goto out;
} }
break; break;
case 0x70: /* Bus error - SDA stuck low */ case 0x70: /* Bus error - SDA stuck low */
DEB2("BUS ERROR - SDA Stuck low\n"); DEB2("BUS ERROR - SDA Stuck low\n");
pca_reset(adap); pca_reset(adap);
return -EREMOTEIO; goto out;
case 0x90: /* Bus error - SCL stuck low */ case 0x90: /* Bus error - SCL stuck low */
DEB2("BUS ERROR - SCL Stuck low\n"); DEB2("BUS ERROR - SCL Stuck low\n");
pca_reset(adap); pca_reset(adap);
return -EREMOTEIO; goto out;
case 0x00: /* Bus error during master or slave mode due to illegal START or STOP condition */ case 0x00: /* Bus error during master or slave mode due to illegal START or STOP condition */
DEB2("BUS ERROR - Illegal START or STOP\n"); DEB2("BUS ERROR - Illegal START or STOP\n");
pca_reset(adap); pca_reset(adap);
return -EREMOTEIO; goto out;
default: default:
printk(KERN_ERR DRIVER ": unhandled SIO state 0x%02x\n", state); printk(KERN_ERR DRIVER ": unhandled SIO state 0x%02x\n", state);
break; break;
...@@ -319,11 +321,13 @@ static int pca_xfer(struct i2c_adapter *i2c_adap, ...@@ -319,11 +321,13 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
} }
DEB1(KERN_CRIT "}}} transfered %d messages. " ret = curmsg;
out:
DEB1(KERN_CRIT "}}} transfered %d/%d messages. "
"status is %#04x. control is %#04x\n", "status is %#04x. control is %#04x\n",
num, pca_status(adap), curmsg, num, pca_status(adap),
pca_get_con(adap)); pca_get_con(adap));
return curmsg; return ret;
} }
static u32 pca_func(struct i2c_adapter *adap) static u32 pca_func(struct i2c_adapter *adap)
......
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