Răsfoiți Sursa

[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>
Russell King 18 ani în urmă
părinte
comite
84b5abe69f
1 a modificat fișierele cu 6 adăugiri și 2 ștergeri
  1. 6 2
      drivers/i2c/busses/i2c-pxa.c

+ 6 - 2
drivers/i2c/busses/i2c-pxa.c

@@ -272,7 +272,8 @@ static int i2c_pxa_wait_slave(struct pxa_i2c *i2c)
 			dev_dbg(&i2c->adap.dev, "%s: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n",
 			dev_dbg(&i2c->adap.dev, "%s: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n",
 				__func__, (long)jiffies, ISR, ICR, IBMR);
 				__func__, (long)jiffies, ISR, ICR, IBMR);
 
 
-		if ((ISR & (ISR_UB|ISR_IBB|ISR_SAD)) == ISR_SAD ||
+		if ((ISR & (ISR_UB|ISR_IBB)) == 0 ||
+		    (ISR & ISR_SAD) != 0 ||
 		    (ICR & ICR_SCLE) == 0) {
 		    (ICR & ICR_SCLE) == 0) {
 			if (i2c_debug > 1)
 			if (i2c_debug > 1)
 				dev_dbg(&i2c->adap.dev, "%s: done\n", __func__);
 				dev_dbg(&i2c->adap.dev, "%s: done\n", __func__);
@@ -492,7 +493,10 @@ static void i2c_pxa_slave_txempty(struct pxa_i2c *i2c, u32 isr)
 	if (isr & ISR_BED) {
 	if (isr & ISR_BED) {
 		/* what should we do here? */
 		/* what should we do here? */
 	} else {
 	} else {
-		int ret = i2c->slave->read(i2c->slave->data);
+		int ret = 0;
+
+		if (i2c->slave != NULL)
+			ret = i2c->slave->read(i2c->slave->data);
 
 
 		IDBR = ret;
 		IDBR = ret;
 		ICR |= ICR_TB;   /* allow next byte */
 		ICR |= ICR_TB;   /* allow next byte */