Skip to content

Commit

Permalink
[PATCH] SCX200_ACB: eliminate spurious timeout errors
Browse files Browse the repository at this point in the history
While busy-waiting for completion, check the hardware after scheduling;
don't schedule and then immediately check the _timeout_.  If the yield()
took a long time (as it does on my OLPC prototype board when it's busy),
we'd report a timeout even though the hardware was now ready.

This fixes it, and also switches the yield() for a cond_resched() because
we don't actually want to be _that_ nice about it.  I see nice
tightly-packed SMBus transactions now, rather than waiting for milliseconds
between successive phases.

Actually, we shouldn't be busy-waiting here at all.  We should be using
interrupts.  That's an exercise for another day though.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Cc: Christer Weinigel <wingel@nano-system.com>
Cc: <Jordan.Crouse@amd.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
dwmw2 authored and Linus Torvalds committed Aug 6, 2006
1 parent 225add6 commit 3e3183b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/i2c/busses/scx200_acb.c
Expand Up @@ -232,7 +232,7 @@ static void scx200_acb_poll(struct scx200_acb_iface *iface)
unsigned long timeout;

timeout = jiffies + POLL_TIMEOUT;
while (time_before(jiffies, timeout)) {
while (1) {
status = inb(ACBST);

/* Reset the status register to avoid the hang */
Expand All @@ -242,7 +242,10 @@ static void scx200_acb_poll(struct scx200_acb_iface *iface)
scx200_acb_machine(iface, status);
return;
}
yield();
if (time_after(jiffies, timeout))
break;
cpu_relax();
cond_resched();
}

dev_err(&iface->adapter.dev, "timeout in state %s\n",
Expand Down

0 comments on commit 3e3183b

Please sign in to comment.