2014-10-31 16:37:01

by Matthias Brugger

[permalink] [raw]
Subject: [PATCH RESEND] tty: serial: 8250_mtk: Fix quot calculation

From: Matthias Brugger <[email protected]>

The calculation of value quot for highspeed register set to three
was wrong. This patch fixes the calculation so that the serial port
for baudrates bigger then 576000 baud is working correctly.

Signed-off-by: Matthias Brugger <[email protected]>
---
drivers/tty/serial/8250/8250_mtk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
index 8f37d57..de7aae5 100644
--- a/drivers/tty/serial/8250/8250_mtk.c
+++ b/drivers/tty/serial/8250/8250_mtk.c
@@ -81,7 +81,7 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
/* Set to highest baudrate supported */
if (baud >= 1152000)
baud = 921600;
- quot = DIV_ROUND_CLOSEST(port->uartclk, 256 * baud);
+ quot = (port->uartclk / (256 * baud)) + 1;
}

/*
--
1.9.1


2014-10-31 16:48:52

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH RESEND] tty: serial: 8250_mtk: Fix quot calculation

On Friday 31 October 2014 17:36:35 Matthias Brugger wrote:
> - quot = DIV_ROUND_CLOSEST(port->uartclk, 256 * baud);
> + quot = (port->uartclk / (256 * baud)) + 1;

Should this be DIV_ROUND_UP then?

Arnd

2014-11-03 02:27:23

by Eddie Huang (黃智傑)

[permalink] [raw]
Subject: Re: [PATCH RESEND] tty: serial: 8250_mtk: Fix quot calculation

On Fri, 2014-10-31 at 17:48 +0100, Arnd Bergmann wrote:
> On Friday 31 October 2014 17:36:35 Matthias Brugger wrote:
> > - quot = DIV_ROUND_CLOSEST(port->uartclk, 256 * baud);
> > + quot = (port->uartclk / (256 * baud)) + 1;
>
> Should this be DIV_ROUND_UP then?
>
> Arnd
>

I think DIV_ROUND_UP is more suitable in this case, and I already do
this and test OK on my MTK platform

http://lists.infradead.org/pipermail/linux-arm-kernel/2014-October/296149.html