serial: Add define for max baud rate divisor
authorEd Blake <ed.blake@sondrel.com>
Tue, 26 Sep 2017 10:40:02 +0000 (11:40 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Oct 2017 08:17:27 +0000 (10:17 +0200)
Add a define for the maximum baud rate divisor, to improve code
readability.

Signed-off-by: Ed Blake <ed.blake@sondrel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/8250/8250_mtk.c
drivers/tty/serial/8250/8250_omap.c
drivers/tty/serial/8250/8250_port.c
include/uapi/linux/serial_reg.h

index fb45770d47aa2adb4166c5b58564e1cad3718acc..fef9823d7b4c6548b3379ee37a4af34880d926cc 100644 (file)
@@ -61,7 +61,7 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
         * registers to their default values.
         */
        baud = uart_get_baud_rate(port, termios, old,
-                                 port->uartclk / 16 / 0xffff,
+                                 port->uartclk / 16 / UART_DIV_MAX,
                                  port->uartclk);
 
        if (baud <= 115200) {
index 833771bca0a593008967905d259c6780cb512cae..4938d338e01fce724cb81c1d1906b1a696808f03 100644 (file)
@@ -199,7 +199,7 @@ static void omap_8250_get_divisor(struct uart_port *port, unsigned int baud,
         * Old custom speed handling.
         */
        if (baud == 38400 && (port->flags & UPF_SPD_MASK) == UPF_SPD_CUST) {
-               priv->quot = port->custom_divisor & 0xffff;
+               priv->quot = port->custom_divisor & UART_DIV_MAX;
                /*
                 * I assume that nobody is using this. But hey, if somebody
                 * would like to specify the divisor _and_ the mode then the
@@ -358,7 +358,7 @@ static void omap_8250_set_termios(struct uart_port *port,
         * Ask the core to calculate the divisor for us.
         */
        baud = uart_get_baud_rate(port, termios, old,
-                                 port->uartclk / 16 / 0xffff,
+                                 port->uartclk / 16 / UART_DIV_MAX,
                                  port->uartclk / 13);
        omap_8250_get_divisor(port, baud, priv);
 
index f0cc04f62b676870551e757b8f006b3e3ff4fa4a..01ab2188a151d713a30e912212cd524b06808e0e 100644 (file)
@@ -2601,7 +2601,7 @@ static unsigned int serial8250_get_baud_rate(struct uart_port *port,
         * causing transmission errors.
         */
        return uart_get_baud_rate(port, termios, old,
-                                 port->uartclk / 16 / 0xffff,
+                                 port->uartclk / 16 / UART_DIV_MAX,
                                  port->uartclk);
 }
 
index 5db76880b4adfc23fc86487d9816ad28df291973..dea05724c7606280162dc84d2d835721b2336eed 100644 (file)
  */
 #define UART_DLL       0       /* Out: Divisor Latch Low */
 #define UART_DLM       1       /* Out: Divisor Latch High */
+#define UART_DIV_MAX   0xFFFF  /* Max divisor value */
 
 /*
  * LCR=0xBF (or DLAB=1 for 16C660)