powerpc/gamecube/wii: Fix off-by-one error in ugecon/usbgecko_udbg
authorAlbert Herranz <albert_herranz@yahoo.es>
Thu, 17 Dec 2009 08:33:41 +0000 (08:33 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fri, 18 Dec 2009 04:13:57 +0000 (15:13 +1100)
The retry logic in ug_putc() is broken.

If the TX fifo is not ready and the counter runs out it will have a
value of -1 and no transfer should be attempted. Also, a counter
with a value of 0 means that the TX fifo got ready in the last try
and the transfer should be attempted.

Reported-by: "Juha Leppanen" <juha_motorsportcom@luukku.com>
Signed-off-by: "Juha Leppanen" <juha_motorsportcom@luukku.com>
Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/boot/ugecon.c
arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c

index 50609ea6ddf8256b078b0f37301ccbdf126df9df..8f2a6b31153439c10cdb2c7fe212beeb689c7103 100644 (file)
@@ -86,7 +86,7 @@ static void ug_putc(char ch)
 
        while (!ug_is_txfifo_ready() && count--)
                barrier();
-       if (count)
+       if (count >= 0)
                ug_raw_putc(ch);
 }
 
index edc956cc8b13a8baf603288e30d41647670009c4..20a8ed91962e9a0f851feb32caf25a44c1ff2d15 100644 (file)
@@ -120,7 +120,7 @@ static void ug_putc(char ch)
 
        while (!ug_is_txfifo_ready() && count--)
                barrier();
-       if (count)
+       if (count >= 0)
                ug_raw_putc(ch);
 }