aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial
diff options
context:
space:
mode:
authorNobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>2014-07-14 03:09:59 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-07-17 21:14:44 -0400
commitbcb9973a6097652a12660958449301aada41de9c (patch)
tree4987eefdf083b0bf5120462de8243a8b94453eb4 /drivers/tty/serial
parentb7d66397f4d282ddf2a2fe516fc9329c5a063459 (diff)
serial: sh-sci: Fix range check of bit-rate for HSCIF
If bit-rate calculation result of HSCIF is expect 255 from 0, driver does not calculate error bit. However, we need to round the value to calculate error bit in the case of negative value. This rounds the value of bit-rate using clamp(), and bit-rate is the case of negative value, it enables the calculation of the error bit. Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial')
-rw-r--r--drivers/tty/serial/sh-sci.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 2ba42069922f..091b65587c7c 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1791,8 +1791,7 @@ static void sci_baud_calc_hscif(unsigned int bps, unsigned long freq,
1791 /* integerized formulas from HSCIF documentation */ 1791 /* integerized formulas from HSCIF documentation */
1792 br = DIV_ROUND_CLOSEST(freq, (sr * 1792 br = DIV_ROUND_CLOSEST(freq, (sr *
1793 (1 << (2 * c + 1)) * bps)) - 1; 1793 (1 << (2 * c + 1)) * bps)) - 1;
1794 if (br < 0 || br > 255) 1794 br = clamp(br, 0, 255);
1795 continue;
1796 err = DIV_ROUND_CLOSEST(freq, ((br + 1) * bps * sr * 1795 err = DIV_ROUND_CLOSEST(freq, ((br + 1) * bps * sr *
1797 (1 << (2 * c + 1)) / 1000)) - 1796 (1 << (2 * c + 1)) / 1000)) -
1798 1000; 1797 1000;