diff options
-rw-r--r-- | drivers/tty/serial/sh-sci.c | 8 | ||||
-rw-r--r-- | include/linux/serial_sci.h | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index eb59bb235a52..f2fad4d8eb9e 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c | |||
@@ -1818,13 +1818,13 @@ static unsigned int sci_scbrr_calc(unsigned int algo_id, unsigned int bps, | |||
1818 | { | 1818 | { |
1819 | switch (algo_id) { | 1819 | switch (algo_id) { |
1820 | case SCBRR_ALGO_1: | 1820 | case SCBRR_ALGO_1: |
1821 | return ((freq + 16 * bps) / (16 * bps) - 1); | 1821 | return freq / (16 * bps); |
1822 | case SCBRR_ALGO_2: | 1822 | case SCBRR_ALGO_2: |
1823 | return ((freq + 16 * bps) / (32 * bps) - 1); | 1823 | return DIV_ROUND_CLOSEST(freq, 32 * bps) - 1; |
1824 | case SCBRR_ALGO_3: | 1824 | case SCBRR_ALGO_3: |
1825 | return (((freq * 2) + 16 * bps) / (16 * bps) - 1); | 1825 | return freq / (8 * bps); |
1826 | case SCBRR_ALGO_4: | 1826 | case SCBRR_ALGO_4: |
1827 | return (((freq * 2) + 16 * bps) / (32 * bps) - 1); | 1827 | return DIV_ROUND_CLOSEST(freq, 16 * bps) - 1; |
1828 | } | 1828 | } |
1829 | 1829 | ||
1830 | /* Warn, but use a safe default */ | 1830 | /* Warn, but use a safe default */ |
diff --git a/include/linux/serial_sci.h b/include/linux/serial_sci.h index babc5fe070b9..12cf50c1c047 100644 --- a/include/linux/serial_sci.h +++ b/include/linux/serial_sci.h | |||
@@ -11,10 +11,10 @@ | |||
11 | #define SCIx_NOT_SUPPORTED (-1) | 11 | #define SCIx_NOT_SUPPORTED (-1) |
12 | 12 | ||
13 | enum { | 13 | enum { |
14 | SCBRR_ALGO_1, /* ((clk + 16 * bps) / (16 * bps) - 1) */ | 14 | SCBRR_ALGO_1, /* clk / (16 * bps) */ |
15 | SCBRR_ALGO_2, /* ((clk + 16 * bps) / (32 * bps) - 1) */ | 15 | SCBRR_ALGO_2, /* DIV_ROUND_CLOSEST(clk, 32 * bps) - 1 */ |
16 | SCBRR_ALGO_3, /* (((clk * 2) + 16 * bps) / (16 * bps) - 1) */ | 16 | SCBRR_ALGO_3, /* clk / (8 * bps) */ |
17 | SCBRR_ALGO_4, /* (((clk * 2) + 16 * bps) / (32 * bps) - 1) */ | 17 | SCBRR_ALGO_4, /* DIV_ROUND_CLOSEST(clk, 16 * bps) - 1 */ |
18 | SCBRR_ALGO_6, /* HSCIF variable sample rate algorithm */ | 18 | SCBRR_ALGO_6, /* HSCIF variable sample rate algorithm */ |
19 | }; | 19 | }; |
20 | 20 | ||