mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-19 05:31:32 +00:00
serial: ns16550: use DIV_ROUND_CLOSEST macro to compute the divisor
The function still returns the same value. The comment block is no longer necessary because our intention is clear enough by using DIV_ROUND_CLOSEST() macro. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
This commit is contained in:
parent
841977df21
commit
f8c7c2033d
1 changed files with 3 additions and 7 deletions
|
@ -130,13 +130,9 @@ static int calc_divisor (NS16550_t port)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MODE_X_DIV 16
|
#define MODE_X_DIV 16
|
||||||
/* Compute divisor value. Normally, we should simply return:
|
|
||||||
* CONFIG_SYS_NS16550_CLK) / MODE_X_DIV / gd->baudrate
|
return DIV_ROUND_CLOSEST(CONFIG_SYS_NS16550_CLK,
|
||||||
* but we need to round that value by adding 0.5.
|
MODE_X_DIV * gd->baudrate);
|
||||||
* Rounding is especially important at high baud rates.
|
|
||||||
*/
|
|
||||||
return (CONFIG_SYS_NS16550_CLK + (gd->baudrate * (MODE_X_DIV / 2))) /
|
|
||||||
(MODE_X_DIV * gd->baudrate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Reference in a new issue