[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130912122135.GP10105@radagast>
Date: Thu, 12 Sep 2013 07:21:35 -0500
From: Felipe Balbi <balbi@...com>
To: Alexey Pelykh <alexey.pelykh@...il.com>
CC: <balbi@...com>, Tony Lindgren <tony@...mide.com>,
Greg KH <gregkh@...uxfoundation.org>,
Linux OMAP Mailing List <linux-omap@...r.kernel.org>,
<linux-serial@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: commit 5fe212364 causes division by zero with large bauds
Hi,
On Thu, Sep 12, 2013 at 07:37:07AM +0300, Alexey Pelykh wrote:
> Actually, here it is, but not formatted properly
>
> diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
> index 816d1a2..146e712 100644
> --- a/drivers/tty/serial/omap-serial.c
> +++ b/drivers/tty/serial/omap-serial.c
> @@ -240,14 +240,14 @@ serial_omap_baud_is_mode16(struct uart_port
> *port, unsigned int baud)
> {
> unsigned int n13 = port->uartclk / (13 * baud);
> unsigned int n16 = port->uartclk / (16 * baud);
> - int baudAbsDiff13 = baud - (port->uartclk / (13 * n13));
> - int baudAbsDiff16 = baud - (port->uartclk / (16 * n16));
> + int baudAbsDiff13 = n13 ? (baud - (port->uartclk / (13 * n13))) : INT_MAX;
> + int baudAbsDiff16 = n16 ? (baud - (port->uartclk / (16 * n16))) : INT_MAX;
> if(baudAbsDiff13 < 0)
> baudAbsDiff13 = -baudAbsDiff13;
> if(baudAbsDiff16 < 0)
> baudAbsDiff16 = -baudAbsDiff16;
>
> - return (baudAbsDiff13 > baudAbsDiff16);
> + return (baudAbsDiff13 >= baudAbsDiff16);
> }
>
> /*
> @@ -258,13 +258,13 @@ serial_omap_baud_is_mode16(struct uart_port
> *port, unsigned int baud)
> static unsigned int
> serial_omap_get_divisor(struct uart_port *port, unsigned int baud)
> {
> - unsigned int divisor;
> + unsigned int mode;
>
> if (!serial_omap_baud_is_mode16(port, baud))
> - divisor = 13;
> + mode = 13;
> else
> - divisor = 16;
> - return port->uartclk/(baud * divisor);
> + mode = 16;
> + return port->uartclk/(mode * baud);
> }
>
> static void serial_omap_enable_ms(struct uart_port *port)
looks good to me, but I'd split it as suggested as a reply to previous
email.
--
balbi
Download attachment "signature.asc" of type "application/pgp-signature" (837 bytes)
Powered by blists - more mailing lists