Add a define for the maximum baud rate divisor, to improve code readability. Signed-off-by: Ed Blake <ed.blake@xxxxxxxxxxx> --- drivers/tty/serial/8250/8250_mtk.c | 2 +- drivers/tty/serial/8250/8250_omap.c | 4 ++-- drivers/tty/serial/8250/8250_port.c | 2 +- include/uapi/linux/serial_reg.h | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c index fb45770..fef9823 100644 --- a/drivers/tty/serial/8250/8250_mtk.c +++ b/drivers/tty/serial/8250/8250_mtk.c @@ -61,7 +61,7 @@ struct mtk8250_data { * 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) { diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c index 833771b..4938d33 100644 --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -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); diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index f0cc04f..01ab218 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -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); } diff --git a/include/uapi/linux/serial_reg.h b/include/uapi/linux/serial_reg.h index 5db7688..dea0572 100644 --- a/include/uapi/linux/serial_reg.h +++ b/include/uapi/linux/serial_reg.h @@ -157,6 +157,7 @@ */ #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) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html