A few drivers still calculate number of frame bits on their own. As core
can do that for them these days, take advantage of core's capabilities.
Ilpo Järvinen (5):
serial: ucc_uart: Remove custom frame size calculation
serial: cpm_uart: Remove custom frame size calculation
serial: fsl_lpuart: Remove custom frame size calculation
serial: sunsab: Remove frame size calculation dead-code
serial: tegra: Remove custom frame size calculation
drivers/tty/serial/cpm_uart/cpm_uart_core.c | 28 ++++++---------------
drivers/tty/serial/fsl_lpuart.c | 10 +++-----
drivers/tty/serial/serial-tegra.c | 12 +++------
drivers/tty/serial/sunsab.c | 20 ++++++---------
drivers/tty/serial/ucc_uart.c | 15 +----------
5 files changed, 22 insertions(+), 63 deletions(-)
--
2.30.2
The driver features a custom frame length calculation but the result is
never used. Remove it.
Signed-off-by: Ilpo Järvinen <[email protected]>
---
drivers/tty/serial/sunsab.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c
index 6ea52293d9f3..f7968f73753d 100644
--- a/drivers/tty/serial/sunsab.c
+++ b/drivers/tty/serial/sunsab.c
@@ -681,27 +681,23 @@ static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cfla
unsigned int quot)
{
unsigned char dafo;
- int bits, n, m;
+ int n, m;
/* Byte size and parity */
switch (cflag & CSIZE) {
- case CS5: dafo = SAB82532_DAFO_CHL5; bits = 7; break;
- case CS6: dafo = SAB82532_DAFO_CHL6; bits = 8; break;
- case CS7: dafo = SAB82532_DAFO_CHL7; bits = 9; break;
- case CS8: dafo = SAB82532_DAFO_CHL8; bits = 10; break;
+ case CS5: dafo = SAB82532_DAFO_CHL5; break;
+ case CS6: dafo = SAB82532_DAFO_CHL6; break;
+ case CS7: dafo = SAB82532_DAFO_CHL7; break;
+ case CS8: dafo = SAB82532_DAFO_CHL8; break;
/* Never happens, but GCC is too dumb to figure it out */
- default: dafo = SAB82532_DAFO_CHL5; bits = 7; break;
+ default: dafo = SAB82532_DAFO_CHL5; break;
}
- if (cflag & CSTOPB) {
+ if (cflag & CSTOPB)
dafo |= SAB82532_DAFO_STOP;
- bits++;
- }
- if (cflag & PARENB) {
+ if (cflag & PARENB)
dafo |= SAB82532_DAFO_PARE;
- bits++;
- }
if (cflag & PARODD) {
dafo |= SAB82532_DAFO_PAR_ODD;
--
2.30.2
The number of bits can be calculated using tty_get_frame_size(), no
need for the driver to do it on its own.
Also remove a comment on number of bits that doesn't match the code nor
the comment on ucc_uart_pram's rx_length ("minus 1" part differs). That
comment seems a verbatim copy of that in cpm_uart/cpm_uart_core.c
anyway so perhaps it was just copied over w/o much thinking.
Signed-off-by: Ilpo Järvinen <[email protected]>
---
drivers/tty/serial/ucc_uart.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
index 3cc9ef08455c..7331964163c5 100644
--- a/drivers/tty/serial/ucc_uart.c
+++ b/drivers/tty/serial/ucc_uart.c
@@ -853,13 +853,6 @@ static void qe_uart_set_termios(struct uart_port *port,
u16 upsmr = ioread16be(&uccp->upsmr);
struct ucc_uart_pram __iomem *uccup = qe_port->uccup;
u16 supsmr = ioread16be(&uccup->supsmr);
- u8 char_length = 2; /* 1 + CL + PEN + 1 + SL */
-
- /* Character length programmed into the mode register is the
- * sum of: 1 start bit, number of data bits, 0 or 1 parity bit,
- * 1 or 2 stop bits, minus 1.
- * The value 'bits' counts this for us.
- */
/* byte size */
upsmr &= UCC_UART_UPSMR_CL_MASK;
@@ -869,22 +862,18 @@ static void qe_uart_set_termios(struct uart_port *port,
case CS5:
upsmr |= UCC_UART_UPSMR_CL_5;
supsmr |= UCC_UART_SUPSMR_CL_5;
- char_length += 5;
break;
case CS6:
upsmr |= UCC_UART_UPSMR_CL_6;
supsmr |= UCC_UART_SUPSMR_CL_6;
- char_length += 6;
break;
case CS7:
upsmr |= UCC_UART_UPSMR_CL_7;
supsmr |= UCC_UART_SUPSMR_CL_7;
- char_length += 7;
break;
default: /* case CS8 */
upsmr |= UCC_UART_UPSMR_CL_8;
supsmr |= UCC_UART_SUPSMR_CL_8;
- char_length += 8;
break;
}
@@ -892,13 +881,11 @@ static void qe_uart_set_termios(struct uart_port *port,
if (termios->c_cflag & CSTOPB) {
upsmr |= UCC_UART_UPSMR_SL;
supsmr |= UCC_UART_SUPSMR_SL;
- char_length++; /* + SL */
}
if (termios->c_cflag & PARENB) {
upsmr |= UCC_UART_UPSMR_PEN;
supsmr |= UCC_UART_SUPSMR_PEN;
- char_length++; /* + PEN */
if (!(termios->c_cflag & PARODD)) {
upsmr &= ~(UCC_UART_UPSMR_RPM_MASK |
@@ -953,7 +940,7 @@ static void qe_uart_set_termios(struct uart_port *port,
iowrite16be(upsmr, &uccp->upsmr);
if (soft_uart) {
iowrite16be(supsmr, &uccup->supsmr);
- iowrite8(char_length, &uccup->rx_length);
+ iowrite8(tty_get_frame_size(termios->c_cflag), &uccup->rx_length);
/* Soft-UART requires a 1X multiplier for TX */
qe_setbrg(qe_port->us_info.rx_clock, baud, 16);
--
2.30.2
On Thu, Aug 25, 2022 at 11:58 AM Ilpo Järvinen
<[email protected]> wrote:
>
> A few drivers still calculate number of frame bits on their own. As core
> can do that for them these days, take advantage of core's capabilities.
For non-commented patches:
Reviewed-by: Andy Shevchenko <[email protected]>
With small style things addressed as suggested, you may spread the tag
to them as well.
> Ilpo Järvinen (5):
> serial: ucc_uart: Remove custom frame size calculation
> serial: cpm_uart: Remove custom frame size calculation
> serial: fsl_lpuart: Remove custom frame size calculation
> serial: sunsab: Remove frame size calculation dead-code
> serial: tegra: Remove custom frame size calculation
>
> drivers/tty/serial/cpm_uart/cpm_uart_core.c | 28 ++++++---------------
> drivers/tty/serial/fsl_lpuart.c | 10 +++-----
> drivers/tty/serial/serial-tegra.c | 12 +++------
> drivers/tty/serial/sunsab.c | 20 ++++++---------
> drivers/tty/serial/ucc_uart.c | 15 +----------
> 5 files changed, 22 insertions(+), 63 deletions(-)
>
> --
> 2.30.2
>
--
With Best Regards,
Andy Shevchenko