[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAOmKuSqh0w8GS-rokCsyF5gBHKWuiy+GvV7P5R8YK264UEG7EA@mail.gmail.com>
Date: Thu, 12 Sep 2013 17:38:32 +0300
From: Alexey Pelykh <alexey.pelykh@...il.com>
To: balbi@...com
Cc: 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
On Thu, Sep 12, 2013 at 3:21 PM, Felipe Balbi <balbi@...com> wrote:
> 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.
Well, the fix of baud rate calculation (giving mode-16 priority) is a
simple >= instead of >.
But indeed, probably commits should be different in terms of their subject.
>
> --
> balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists