Skip to contentSkip to conversation

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

PATCH In review Mike Ditto 3 participants 4 messages Nov 1, 2008 – Nov 3, 2008 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Mike Ditto

author
#0 lore raw

PATCH 1/1 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.

Index: linux/drivers/i2c/busses/i2c-cpm.c
===================================================================
retrieving revision 1.3

drivers/i2c/busses/i2c-cpm.c +1 -0
diff -u -p -r1.3 i2c-cpm.c
@@ -369,6 +369,7 @@ static int cpm_i2c_xfer(struct i2c_adapt
 		pmsg = &msgs[tptr];
 		if (pmsg->flags & I2C_M_RD)
 			ret = wait_event_interruptible_timeout(cpm->i2c_wait,
+				(in_be16(&tbdf[tptr].cbd_sc) & BD_SC_NAK) ||
 				!(in_be16(&rbdf[rptr].cbd_sc) & BD_SC_EMPTY),
 				1 * HZ);
 		else

A message that is not in the archive (sent off-list or not yet received): 490BA2E5.8010309-Vjf7OWgA3BLqlBn2x/[email protected]

#2 lore raw
Quoted 9 lines · Mike Ditto

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.

hmm, that block of text could probably go into the patch description.

It looks ok, I'll merge and push out to linus with the s3c fixes.

Quoted 18 lines

Index: linux/drivers/i2c/busses/i2c-cpm.c
===================================================================
retrieving revision 1.3
diff -u -p -r1.3 i2c-cpm.c

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

To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 3 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#4 lore raw
Quoted 6 lines · Ben Dooks
Quoted 4 lines

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.

hmm, that block of text could probably go into the patch description.

It's certainly fine with me if you want to include it. I was just trying, perhaps inappropriately, to separate the "bug report" from the "description of the change".

					-=] Mike [=-