Commit a804644a1a31a0b85e4c7d3c49f30419513cb6c1

Authored by Mike Ditto
Committed by Ben Dooks
1 parent 1bda71282d

i2c-cpm: Detect and report NAK right away instead of timing out

Make the driver report an ENXIO error immediately upon NAK instead of
waiting for another interrupt and getting a timeout.

When reading from a device that is not present or declines to respond
to, e.g., a non-existent register address, CPM immediately reports a
NAK condition in the TxBD, but the driver kept waiting until a timeout,
which takes 1 second and causes an ugly console error message.

Signed-off-by: Mike Ditto <mditto@consentry.com>
Acked-by: Jochen Friedrich <jochen@scram.de>
[ben-linux@fluff.org: reordered description text]
Signed-off-by: Ben Dooks <ben-linux@fluff.org>

Showing 1 changed file with 1 additions and 0 deletions Side-by-side Diff

drivers/i2c/busses/i2c-cpm.c
... ... @@ -365,6 +365,7 @@
365 365 pmsg = &msgs[tptr];
366 366 if (pmsg->flags & I2C_M_RD)
367 367 ret = wait_event_interruptible_timeout(cpm->i2c_wait,
  368 + (in_be16(&tbdf[tptr].cbd_sc) & BD_SC_NAK) ||
368 369 !(in_be16(&rbdf[rptr].cbd_sc) & BD_SC_EMPTY),
369 370 1 * HZ);
370 371 else