From: Laurent Pinchart Date: Thu, 20 Nov 2008 12:32:23 +0000 (+0100) Subject: cpm2: Round the baud-rate clock divider to the nearest integer. X-Git-Tag: v2.6.30-rc1~619^2~130^2~13 X-Git-Url: http://ftp.safe.ca/?a=commitdiff_plain;h=7b8909940a524d67b4352c29256ada476f50fbba;p=safe%2Fjmp%2Flinux-2.6 cpm2: Round the baud-rate clock divider to the nearest integer. Instead of rounding the divider down, improve the baud-rate generators accuracy by rounding to the nearest integer. Signed-off-by: Laurent Pinchart Signed-off-by: Kumar Gala --- diff --git a/arch/powerpc/sysdev/cpm2.c b/arch/powerpc/sysdev/cpm2.c index f1c3395..474d176 100644 --- a/arch/powerpc/sysdev/cpm2.c +++ b/arch/powerpc/sysdev/cpm2.c @@ -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;