提交 988c5bbe 编写于 作者: J Jiri Slaby 提交者: Greg Kroah-Hartman

tty: serial: make use of UART_LCR_WLEN() + tty_get_char_size()

Having a generic UART_LCR_WLEN() macro and the tty_get_char_size()
helper, we can remove all those repeated switch-cases in drivers.

Cc: Laxman Dewangan <ldewangan@nvidia.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: linux-tegra@vger.kernel.org
Reviewed-by: NThierry Reding <treding@nvidia.com>
Signed-off-by: NJiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20220224095558.30929-2-jslaby@suse.czSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 797bd4d4
...@@ -357,21 +357,7 @@ static void omap_8250_set_termios(struct uart_port *port, ...@@ -357,21 +357,7 @@ static void omap_8250_set_termios(struct uart_port *port,
unsigned char cval = 0; unsigned char cval = 0;
unsigned int baud; unsigned int baud;
switch (termios->c_cflag & CSIZE) { cval = UART_LCR_WLEN(tty_get_char_size(termios->c_cflag));
case CS5:
cval = UART_LCR_WLEN5;
break;
case CS6:
cval = UART_LCR_WLEN6;
break;
case CS7:
cval = UART_LCR_WLEN7;
break;
default:
case CS8:
cval = UART_LCR_WLEN8;
break;
}
if (termios->c_cflag & CSTOPB) if (termios->c_cflag & CSTOPB)
cval |= UART_LCR_STOP; cval |= UART_LCR_STOP;
......
...@@ -2605,21 +2605,7 @@ static unsigned char serial8250_compute_lcr(struct uart_8250_port *up, ...@@ -2605,21 +2605,7 @@ static unsigned char serial8250_compute_lcr(struct uart_8250_port *up,
{ {
unsigned char cval; unsigned char cval;
switch (c_cflag & CSIZE) { cval = UART_LCR_WLEN(tty_get_char_size(c_cflag));
case CS5:
cval = UART_LCR_WLEN5;
break;
case CS6:
cval = UART_LCR_WLEN6;
break;
case CS7:
cval = UART_LCR_WLEN7;
break;
default:
case CS8:
cval = UART_LCR_WLEN8;
break;
}
if (c_cflag & CSTOPB) if (c_cflag & CSTOPB)
cval |= UART_LCR_STOP; cval |= UART_LCR_STOP;
......
...@@ -737,21 +737,7 @@ static void cls_param(struct jsm_channel *ch) ...@@ -737,21 +737,7 @@ static void cls_param(struct jsm_channel *ch)
if (ch->ch_c_cflag & CSTOPB) if (ch->ch_c_cflag & CSTOPB)
lcr |= UART_LCR_STOP; lcr |= UART_LCR_STOP;
switch (ch->ch_c_cflag & CSIZE) { lcr |= UART_LCR_WLEN(tty_get_char_size(ch->ch_c_cflag));
case CS5:
lcr |= UART_LCR_WLEN5;
break;
case CS6:
lcr |= UART_LCR_WLEN6;
break;
case CS7:
lcr |= UART_LCR_WLEN7;
break;
case CS8:
default:
lcr |= UART_LCR_WLEN8;
break;
}
ier = readb(&ch->ch_cls_uart->ier); ier = readb(&ch->ch_cls_uart->ier);
uart_lcr = readb(&ch->ch_cls_uart->lcr); uart_lcr = readb(&ch->ch_cls_uart->lcr);
......
...@@ -1008,21 +1008,7 @@ static void neo_param(struct jsm_channel *ch) ...@@ -1008,21 +1008,7 @@ static void neo_param(struct jsm_channel *ch)
if (ch->ch_c_cflag & CSTOPB) if (ch->ch_c_cflag & CSTOPB)
lcr |= UART_LCR_STOP; lcr |= UART_LCR_STOP;
switch (ch->ch_c_cflag & CSIZE) { lcr |= UART_LCR_WLEN(tty_get_char_size(ch->ch_c_cflag));
case CS5:
lcr |= UART_LCR_WLEN5;
break;
case CS6:
lcr |= UART_LCR_WLEN6;
break;
case CS7:
lcr |= UART_LCR_WLEN7;
break;
case CS8:
default:
lcr |= UART_LCR_WLEN8;
break;
}
ier = readb(&ch->ch_neo_uart->ier); ier = readb(&ch->ch_neo_uart->ier);
uart_lcr = readb(&ch->ch_neo_uart->lcr); uart_lcr = readb(&ch->ch_neo_uart->lcr);
......
...@@ -808,21 +808,7 @@ serial_omap_set_termios(struct uart_port *port, struct ktermios *termios, ...@@ -808,21 +808,7 @@ serial_omap_set_termios(struct uart_port *port, struct ktermios *termios,
unsigned long flags; unsigned long flags;
unsigned int baud, quot; unsigned int baud, quot;
switch (termios->c_cflag & CSIZE) { cval = UART_LCR_WLEN(tty_get_char_size(termios->c_cflag));
case CS5:
cval = UART_LCR_WLEN5;
break;
case CS6:
cval = UART_LCR_WLEN6;
break;
case CS7:
cval = UART_LCR_WLEN7;
break;
default:
case CS8:
cval = UART_LCR_WLEN8;
break;
}
if (termios->c_cflag & CSTOPB) if (termios->c_cflag & CSTOPB)
cval |= UART_LCR_STOP; cval |= UART_LCR_STOP;
......
...@@ -430,21 +430,7 @@ serial_pxa_set_termios(struct uart_port *port, struct ktermios *termios, ...@@ -430,21 +430,7 @@ serial_pxa_set_termios(struct uart_port *port, struct ktermios *termios,
unsigned int baud, quot; unsigned int baud, quot;
unsigned int dll; unsigned int dll;
switch (termios->c_cflag & CSIZE) { cval = UART_LCR_WLEN(tty_get_char_size(termios->c_cflag));
case CS5:
cval = UART_LCR_WLEN5;
break;
case CS6:
cval = UART_LCR_WLEN6;
break;
case CS7:
cval = UART_LCR_WLEN7;
break;
default:
case CS8:
cval = UART_LCR_WLEN8;
break;
}
if (termios->c_cflag & CSTOPB) if (termios->c_cflag & CSTOPB)
cval |= UART_LCR_STOP; cval |= UART_LCR_STOP;
......
...@@ -1277,6 +1277,7 @@ static void tegra_uart_set_termios(struct uart_port *u, ...@@ -1277,6 +1277,7 @@ static void tegra_uart_set_termios(struct uart_port *u,
unsigned int baud; unsigned int baud;
unsigned long flags; unsigned long flags;
unsigned int lcr; unsigned int lcr;
unsigned char char_bits;
int symb_bit = 1; int symb_bit = 1;
struct clk *parent_clk = clk_get_parent(tup->uart_clk); struct clk *parent_clk = clk_get_parent(tup->uart_clk);
unsigned long parent_clk_rate = clk_get_rate(parent_clk); unsigned long parent_clk_rate = clk_get_rate(parent_clk);
...@@ -1316,25 +1317,10 @@ static void tegra_uart_set_termios(struct uart_port *u, ...@@ -1316,25 +1317,10 @@ static void tegra_uart_set_termios(struct uart_port *u,
} }
} }
char_bits = tty_get_char_size(termios->c_cflag);
symb_bit += char_bits;
lcr &= ~UART_LCR_WLEN8; lcr &= ~UART_LCR_WLEN8;
switch (termios->c_cflag & CSIZE) { lcr |= UART_LCR_WLEN(char_bits);
case CS5:
lcr |= UART_LCR_WLEN5;
symb_bit += 5;
break;
case CS6:
lcr |= UART_LCR_WLEN6;
symb_bit += 6;
break;
case CS7:
lcr |= UART_LCR_WLEN7;
symb_bit += 7;
break;
default:
lcr |= UART_LCR_WLEN8;
symb_bit += 8;
break;
}
/* Stop bits */ /* Stop bits */
if (termios->c_cflag & CSTOPB) { if (termios->c_cflag & CSTOPB) {
......
...@@ -504,20 +504,7 @@ static void siu_set_termios(struct uart_port *port, struct ktermios *new, ...@@ -504,20 +504,7 @@ static void siu_set_termios(struct uart_port *port, struct ktermios *new,
unsigned long flags; unsigned long flags;
c_cflag = new->c_cflag; c_cflag = new->c_cflag;
switch (c_cflag & CSIZE) { lcr = UART_LCR_WLEN(tty_get_char_size(c_cflag));
case CS5:
lcr = UART_LCR_WLEN5;
break;
case CS6:
lcr = UART_LCR_WLEN6;
break;
case CS7:
lcr = UART_LCR_WLEN7;
break;
default:
lcr = UART_LCR_WLEN8;
break;
}
if (c_cflag & CSTOPB) if (c_cflag & CSTOPB)
lcr |= UART_LCR_STOP; lcr |= UART_LCR_STOP;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册