]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
cpm2: Round the baud-rate clock divider to the nearest integer.
authorLaurent Pinchart <laurentp@cse-semaphore.com>
Thu, 20 Nov 2008 12:32:23 +0000 (13:32 +0100)
committerKumar Gala <galak@kernel.crashing.org>
Thu, 29 Jan 2009 00:16:57 +0000 (18:16 -0600)
Instead of rounding the divider down, improve the baud-rate generators
accuracy by rounding to the nearest integer.

Signed-off-by: Laurent Pinchart <laurentp@cse-semaphore.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
arch/powerpc/sysdev/cpm2.c

index f1c3395633b9aedebda4c1979e6801f659c9fa40..474d176a6ec3a52ad8ed5abd5959448bd545ca25 100644 (file)
@@ -129,7 +129,8 @@ void __cpm2_setbrg(uint brg, uint rate, uint clk, int div16, int src)
                brg -= 4;
        }
        bp += brg;
-       val = (((clk / rate) - 1) << 1) | CPM_BRG_EN | src;
+       /* Round the clock divider to the nearest integer. */
+       val = (((clk * 2 / rate) - 1) & ~1) | CPM_BRG_EN | src;
        if (div16)
                val |= CPM_BRG_DIV16;