aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/sh-sci.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2013-12-06 04:59:12 -0500
committerSimon Horman <horms+renesas@verge.net.au>2013-12-23 21:17:33 -0500
commit6557b1f69ea0961efde7ab33bfe0cb7e3bfed54e (patch)
tree6b80f503c2968778ed6e0d7e20a1a7e34db1de50 /drivers/tty/serial/sh-sci.c
parent6db201da2522d7dd231982ff7b83916cf4db3e41 (diff)
serial: sh-sci: Simplify baud rate calculation algorithms
Rewrite the baud rate register value calculations in easier to read forms. The computed value isn't modified. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Diffstat (limited to 'drivers/tty/serial/sh-sci.c')
-rw-r--r--drivers/tty/serial/sh-sci.c8
1 files changed, 4 insertions, 4 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 */