mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-24 21:54:01 +00:00
serial: zynq: Use DIV_ROUND_CLOSEST() to calcurate divider value
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>
This commit is contained in:
parent
65fc1697db
commit
c6bceb4e36
1 changed files with 1 additions and 1 deletions
|
@ -75,7 +75,7 @@ static void _uart_zynq_serial_setbrg(struct uart_zynq *regs,
|
||||||
* Find acceptable values for baud generation.
|
* Find acceptable values for baud generation.
|
||||||
*/
|
*/
|
||||||
for (bdiv = 4; bdiv < 255; bdiv++) {
|
for (bdiv = 4; bdiv < 255; bdiv++) {
|
||||||
bgen = clock / (baud * (bdiv + 1));
|
bgen = DIV_ROUND_CLOSEST(clock, baud * (bdiv + 1));
|
||||||
if (bgen < 2 || bgen > 65535)
|
if (bgen < 2 || bgen > 65535)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue