[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>

authored by Russell King and committed by Russell King 84b5abe6 e0f205d9

+6 -2
+6 -2
drivers/i2c/busses/i2c-pxa.c
··· 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__); ··· 493 492 if (isr & ISR_BED) { 494 493 /* what should we do here? */ 495 494 } else { 496 - int ret = i2c->slave->read(i2c->slave->data); 495 + int ret = 0; 496 + 497 + if (i2c->slave != NULL) 498 + ret = i2c->slave->read(i2c->slave->data); 497 499 498 500 IDBR = ret; 499 501 ICR |= ICR_TB; /* allow next byte */