sh: heartbeat double 0 fix.
authorTakashi YOSHII <takashi.yoshii.ze@hitachi.com>
Mon, 12 Mar 2007 06:33:22 +0000 (15:33 +0900)
committerPaul Mundt <lethal@hera.kernel.org>
Mon, 7 May 2007 02:10:53 +0000 (02:10 +0000)
This implements stricter and more compliant knightrider strobing in the
heartbeat handler. While there still seems to be some debate as to
whether the double 0 is "more" correct or not, this updated version
appears to have general consensus. Fixes a long-term "bug".

Signed-off-by: Takashi YOSHII <takashi.yoshii.ze@hitachi.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/drivers/heartbeat.c

index bc59cb6cd78b24a9799cb2ebd8ee60e6b32a5474..23dd6080422f155cdb422b7f373e2964eedf41d6 100644 (file)
@@ -40,16 +40,9 @@ static void heartbeat_timer(unsigned long data)
        static unsigned bit = 0, up = 1;
 
        ctrl_outw(1 << hd->bit_pos[bit], (unsigned long)hd->base);
-       if (up)
-               if (bit == (ARRAY_SIZE(hd->bit_pos) - 1)) {
-                       bit--;
-                       up = 0;
-               } else
-                       bit++;
-       else if (bit == 0)
-               up = 1;
-       else
-               bit--;
+       bit += up;
+       if ((bit == 0) || (bit == ARRAY_SIZE(hd->bit_pos)-1))
+               up = -up;
 
        mod_timer(&hd->timer, jiffies + (110 - ((300 << FSHIFT) /
                        ((avenrun[0] / 5) + (3 << FSHIFT)))));