Commit 84b5abe69ff600a559e1a1fa29f1edad707d4e2f

Authored by Russell King
Committed by Russell King
1 parent e0f205d9c6

[ARM] Fix i2c-pxa slave mode support

i2c-pxa times out when trying to enable slave mode due to an
incorrect test.  Also, check that i2c->slave is non-NULL
before dereferencing it.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

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

drivers/i2c/busses/i2c-pxa.c
... ... @@ -272,7 +272,8 @@
272 272 dev_dbg(&i2c->adap.dev, "%s: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n",
273 273 __func__, (long)jiffies, ISR, ICR, IBMR);
274 274  
275   - if ((ISR & (ISR_UB|ISR_IBB|ISR_SAD)) == ISR_SAD ||
  275 + if ((ISR & (ISR_UB|ISR_IBB)) == 0 ||
  276 + (ISR & ISR_SAD) != 0 ||
276 277 (ICR & ICR_SCLE) == 0) {
277 278 if (i2c_debug > 1)
278 279 dev_dbg(&i2c->adap.dev, "%s: done\n", __func__);
... ... @@ -492,7 +493,10 @@
492 493 if (isr & ISR_BED) {
493 494 /* what should we do here? */
494 495 } else {
495   - int ret = i2c->slave->read(i2c->slave->data);
  496 + int ret = 0;
  497 +
  498 + if (i2c->slave != NULL)
  499 + ret = i2c->slave->read(i2c->slave->data);
496 500  
497 501 IDBR = ret;
498 502 ICR |= ICR_TB; /* allow next byte */