Commit b9ae68e4 authored by Roger Blofeld's avatar Roger Blofeld Committed by Russell King

[SERIAL] Pick nearest baud rate divider

From: Roger Blofeld

This patch modifies uart_get_divisor to select the nearest baud rate
divider rather than the lowest.  It minimizes baud rate errors.

For example, if uartclk is 33000000 and baud is 115200 the ratio is about
17.9 The current code selects 17 (5% error) but should select 18 (0.5%
error)

Signed-off-by: Andrew Morton
Signed-off-by: Russell King
parent 4b3df94c
......@@ -395,7 +395,7 @@ uart_get_divisor(struct uart_port *port, unsigned int baud)
if (baud == 38400 && (port->flags & UPF_SPD_MASK) == UPF_SPD_CUST)
quot = port->custom_divisor;
else
quot = port->uartclk / (16 * baud);
quot = (port->uartclk + (8 * baud)) / (16 * baud);
return quot;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment