]> git.baikalelectronics.ru Git - kernel.git/commit
serial: st-asc: Fix overflow in baudrate calculation
authorMaxime COQUELIN <maxime.coquelin@st.com>
Thu, 24 Jul 2014 12:02:56 +0000 (14:02 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 27 Jul 2014 18:05:08 +0000 (11:05 -0700)
commita059532408d6c8c77885edfba5428455279e4ef3
treeb2455df55830e09ef16570289e5bc741bfbf75cf
parentccdd3780999d336c56f1c31178f7824f9a8feae2
serial: st-asc: Fix overflow in baudrate calculation

In the current calculation, if the required baud rate is above 262143,
we get an overflow.

This patch uses a 64bits variable to do the maths.
Also, we remove the '+1' to avoid a divide by zero if the input clock
rate is something unexpected.
Indeed, if the input clock rate is zero, it is preferable to be notified,
since the UART won't work anyway.

Signed-off-by: Maxime Coquelin <maxime.coquelin@st.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/st-asc.c