Re: commit 5fe212364 causes division by zero with large bauds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 12, 2013 at 3:21 PM, Felipe Balbi <balbi@xxxxxx> 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-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux