Skip to content

Commit

Permalink
cpm2: Round the baud-rate clock divider to the nearest integer.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Laurent Pinchart authored and Kumar Gala committed Jan 29, 2009
1 parent 9605146 commit 7b89099
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arch/powerpc/sysdev/cpm2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 7b89099

Please sign in to comment.