Skip to contentSkip to conversation

i2c: scx200_acb - fix poll loop

PATCH New Ben Gardner 1 participant 2 messages Dec 19, 2005 – Dec 20, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 6/7 i2c: scx200_acb - fix poll loop

Fix and speed up the poll loop.
The delay(10) was just too much of a delay, I changed it to a yield(). The large delay was causing the NACK in the address state to be missed, so instead of getting a NACK, we were getting a timeout. I also shortened the timeout to HZ/5, as 1 second was excessive.

Signed-off-by: Ben Gardner <bgardner at wabtec.com> -------------- next part --------------

 drivers/i2c/busses/scx200_acb.c |   13 ++-----------
 1 files changed, 2 insertions(+), 11 deletions(-)
drivers/i2c/busses/scx200_acb.c +2 -11
@@ -47,10 +47,7 @@ static int base[MAX_DEVICES] = { 0x820, 
 module_param_array(base, int, NULL, 0);
 MODULE_PARM_DESC(base, "Base addresses for the ACCESS.bus controllers");
 
-/* The hardware supports interrupt driven mode too, but I haven't
-   implemented that. */
-#define POLLED_MODE	1
-#define POLL_TIMEOUT	(HZ)
+#define POLL_TIMEOUT	(HZ/5)
 
 enum scx200_acb_state {
 	state_idle,
@@ -223,7 +220,6 @@ static void scx200_acb_machine(struct sc
 	iface->needs_reset = 1;
 }
 
-#ifdef POLLED_MODE
 static void scx200_acb_poll(struct scx200_acb_iface *iface)
 {
 	u8		status;
@@ -236,7 +232,7 @@ static void scx200_acb_poll(struct scx20
 			scx200_acb_machine(iface, status);
 			return;
 		}
-		msleep(10);
+		yield();
 	}
 
 	dev_err(&iface->adapter.dev, "timeout in state %s\n",
@@ -246,7 +242,6 @@ static void scx200_acb_poll(struct scx20
 	iface->result      = -EIO;
 	iface->needs_reset = 1;
 }
-#endif /* POLLED_MODE */
 
 static void scx200_acb_reset(struct scx200_acb_iface *iface)
 {
@@ -341,12 +336,8 @@ static s32 scx200_acb_smbus_xfer(struct 
 	else
 		iface->state = state_address;
 
-#ifdef POLLED_MODE
 	while (iface->state != state_idle)
 		scx200_acb_poll(iface);
-#else /* POLLED_MODE */
-#error Interrupt driven mode not implemented
-#endif /* POLLED_MODE */	
 
 	if (iface->needs_reset)
 		scx200_acb_reset(iface);
#1 lore raw

PATCH 6/7 i2c: scx200_acb - fix poll loop

scx200_acb: Fix and speed up the poll loop

Signed-off-by Ben Gardner <bgardner at wabtec.com>

---
This is the second version of the series.
-------------- next part --------------

 drivers/i2c/busses/scx200_acb.c |   13 ++-----------
 1 files changed, 2 insertions(+), 11 deletions(-)
drivers/i2c/busses/scx200_acb.c +2 -11
@@ -47,10 +47,7 @@ static int base[MAX_DEVICES] = { 0x820, 
 module_param_array(base, int, NULL, 0);
 MODULE_PARM_DESC(base, "Base addresses for the ACCESS.bus controllers");
 
-/* The hardware supports interrupt driven mode too, but I haven't
-   implemented that. */
-#define POLLED_MODE 1
-#define POLL_TIMEOUT (HZ)
+#define POLL_TIMEOUT	(HZ/5)
 
 enum scx200_acb_state {
 	state_idle,
@@ -222,7 +219,6 @@ static void scx200_acb_machine(struct sc
 	iface->needs_reset = 1;
 }
 
-#ifdef POLLED_MODE
 static void scx200_acb_poll(struct scx200_acb_iface *iface)
 {
 	u8 status;
@@ -235,7 +231,7 @@ static void scx200_acb_poll(struct scx20
 			scx200_acb_machine(iface, status);
 			return;
 		}
-		msleep(10);
+		yield();
 	}
 
 	dev_err(&iface->adapter.dev, "timeout in state %s\n",
@@ -245,7 +241,6 @@ static void scx200_acb_poll(struct scx20
 	iface->result = -EIO;
 	iface->needs_reset = 1;
 }
-#endif /* POLLED_MODE */
 
 static void scx200_acb_reset(struct scx200_acb_iface *iface)
 {
@@ -335,12 +330,8 @@ static s32 scx200_acb_smbus_xfer(struct 
 	else
 		iface->state = state_address;
 
-#ifdef POLLED_MODE
 	while (iface->state != state_idle)
 		scx200_acb_poll(iface);
-#else /* POLLED_MODE */
-#error Interrupt driven mode not implemented
-#endif /* POLLED_MODE */	
 
 	if (iface->needs_reset)
 		scx200_acb_reset(iface);