diff options
author | Masahiro Yamada <yamada.m@jp.panasonic.com> | 2014-07-11 20:29:03 +0900 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2014-07-22 07:44:25 -0400 |
commit | f8c7c2033df1f8aa1cd329292f01e87972d84535 (patch) | |
tree | fb271d0907cb1c387bbdadb49d7b796ec6f86e74 /drivers | |
parent | 841977df21e5f2c1276ae5a33cca3ac4fb976ad9 (diff) | |
download | u-boot-imx-f8c7c2033df1f8aa1cd329292f01e87972d84535.zip u-boot-imx-f8c7c2033df1f8aa1cd329292f01e87972d84535.tar.gz u-boot-imx-f8c7c2033df1f8aa1cd329292f01e87972d84535.tar.bz2 |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/serial/serial_ns16550.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c index 056ef2a..49e2c1f 100644 --- a/drivers/serial/serial_ns16550.c +++ b/drivers/serial/serial_ns16550.c @@ -130,13 +130,9 @@ static int calc_divisor (NS16550_t port) #endif #define MODE_X_DIV 16 - /* Compute divisor value. Normally, we should simply return: - * CONFIG_SYS_NS16550_CLK) / MODE_X_DIV / gd->baudrate - * but we need to round that value by adding 0.5. - * Rounding is especially important at high baud rates. - */ - return (CONFIG_SYS_NS16550_CLK + (gd->baudrate * (MODE_X_DIV / 2))) / - (MODE_X_DIV * gd->baudrate); + + return DIV_ROUND_CLOSEST(CONFIG_SYS_NS16550_CLK, + MODE_X_DIV * gd->baudrate); } void |