projects
/
u-boot.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
65fc169
)
serial: zynq: Use DIV_ROUND_CLOSEST() to calcurate divider value
author
Kunihiko Hayashi
<hayashi.kunihiko@socionext.com>
Wed, 13 Jul 2022 01:38:59 +0000
(10:38 +0900)
committer
Michal Simek
<michal.simek@amd.com>
Tue, 26 Jul 2022 06:23:55 +0000
(08:23 +0200)
Since the calulation of "bgen" is rounded down, using a higher
baudrate will result in a larger difference from the actual
baudrate. Should use DIV_ROUND_CLOSEST() like the Linux driver.
Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Link:
https://lore.kernel.org/r/1657676339-6055-1-git-send-email-hayashi.kunihiko@socionext.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
drivers/serial/serial_zynq.c
patch
|
blob
|
history
diff --git
a/drivers/serial/serial_zynq.c
b/drivers/serial/serial_zynq.c
index 83adfb5fb98ab1ad53a70c1cd2319c3146bbb52b..295337a817637391ff3e30d270f75b0062c26a1d 100644
(file)
--- a/
drivers/serial/serial_zynq.c
+++ b/
drivers/serial/serial_zynq.c
@@
-75,7
+75,7
@@
static void _uart_zynq_serial_setbrg(struct uart_zynq *regs,
* Find acceptable values for baud generation.
*/
for (bdiv = 4; bdiv < 255; bdiv++) {
- bgen =
clock / (
baud * (bdiv + 1));
+ bgen =
DIV_ROUND_CLOSEST(clock,
baud * (bdiv + 1));
if (bgen < 2 || bgen > 65535)
continue;