Commit c25e509a authored by Russell King's avatar Russell King Committed by Wolfram Sang

i2c: pxa: avoid complaints with non-responsive slaves

Running i2cdetect on a PXA I2C adapter is very noisy; it complains
whenever a slave fails to respond to the address cycle.  Since it is
normal to probe for slaves in this way, we should not fill the kernel
log.  This is especially true with SFP modules that take a while to
respond on the I2C bus, and probing via the I2C bus is the only way to
detect that they are ready.

Fix this by changing the internal transfer return code from I2C_RETRY
to a new NO_SLAVE code (mapped to -ENXIO, as per the I2C documentation
for this condition, but we still return -EREMOTEIO to the I2C stack to
maintain long established driver behaviour.)
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent 0f03c088
...@@ -90,6 +90,7 @@ ...@@ -90,6 +90,7 @@
*/ */
#define DEF_TIMEOUT 32 #define DEF_TIMEOUT 32
#define NO_SLAVE (-ENXIO)
#define BUS_ERROR (-EREMOTEIO) #define BUS_ERROR (-EREMOTEIO)
#define XFER_NAKED (-ECONNREFUSED) #define XFER_NAKED (-ECONNREFUSED)
#define I2C_RETRY (-2000) /* an error has occurred retry transmit */ #define I2C_RETRY (-2000) /* an error has occurred retry transmit */
...@@ -881,7 +882,7 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c, u32 isr) ...@@ -881,7 +882,7 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c, u32 isr)
*/ */
if (isr & ISR_ACKNAK) { if (isr & ISR_ACKNAK) {
if (i2c->msg_ptr == 0 && i2c->msg_idx == 0) if (i2c->msg_ptr == 0 && i2c->msg_idx == 0)
ret = I2C_RETRY; ret = NO_SLAVE;
else else
ret = XFER_NAKED; ret = XFER_NAKED;
} }
...@@ -1109,16 +1110,19 @@ static int i2c_pxa_internal_xfer(struct pxa_i2c *i2c, ...@@ -1109,16 +1110,19 @@ static int i2c_pxa_internal_xfer(struct pxa_i2c *i2c,
{ {
int ret, i; int ret, i;
for (i = i2c->adap.retries; i >= 0; i--) { for (i = 0; ; ) {
ret = xfer(i2c, msgs, num); ret = xfer(i2c, msgs, num);
if (ret != I2C_RETRY) if (ret != I2C_RETRY && ret != NO_SLAVE)
goto out; goto out;
if (++i >= i2c->adap.retries)
break;
if (i2c_debug) if (i2c_debug)
dev_dbg(&i2c->adap.dev, "Retrying transmission\n"); dev_dbg(&i2c->adap.dev, "Retrying transmission\n");
udelay(100); udelay(100);
} }
i2c_pxa_scream_blue_murder(i2c, "exhausted retries"); if (ret != NO_SLAVE)
i2c_pxa_scream_blue_murder(i2c, "exhausted retries");
ret = -EREMOTEIO; ret = -EREMOTEIO;
out: out:
i2c_pxa_set_slave(i2c, ret); i2c_pxa_set_slave(i2c, ret);
......
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