diff mbox series

[4/5] sdio_uart: make use of UART_LCR_WLEN() + tty_get_char_size()

Message ID 20220224095558.30929-4-jslaby@suse.cz
State New
Headers show
Series None | expand

Commit Message

Jiri Slaby Feb. 24, 2022, 9:55 a.m. UTC
Having a generic UART_LCR_WLEN() macro and the tty_get_char_size()
helper, we can remove all those repeated switch-cases in drivers.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: linux-mmc@vger.kernel.org
---
 drivers/mmc/core/sdio_uart.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

Comments

Ulf Hansson Feb. 28, 2022, 4:16 p.m. UTC | #1
On Thu, 24 Feb 2022 at 10:56, Jiri Slaby <jslaby@suse.cz> wrote:
>
> Having a generic UART_LCR_WLEN() macro and the tty_get_char_size()
> helper, we can remove all those repeated switch-cases in drivers.
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: linux-mmc@vger.kernel.org

Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

> ---
>  drivers/mmc/core/sdio_uart.c | 16 +---------------
>  1 file changed, 1 insertion(+), 15 deletions(-)
>
> diff --git a/drivers/mmc/core/sdio_uart.c b/drivers/mmc/core/sdio_uart.c
> index 04c0823e0359..e6eb5bd6e440 100644
> --- a/drivers/mmc/core/sdio_uart.c
> +++ b/drivers/mmc/core/sdio_uart.c
> @@ -250,21 +250,7 @@ static void sdio_uart_change_speed(struct sdio_uart_port *port,
>         unsigned char cval, fcr = 0;
>         unsigned int baud, quot;
>
> -       switch (termios->c_cflag & CSIZE) {
> -       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;
> -       }
> +       cval = UART_LCR_WLEN(tty_get_char_size(termios->c_cflag));
>
>         if (termios->c_cflag & CSTOPB)
>                 cval |= UART_LCR_STOP;
> --
> 2.35.1
>
diff mbox series

Patch

diff --git a/drivers/mmc/core/sdio_uart.c b/drivers/mmc/core/sdio_uart.c
index 04c0823e0359..e6eb5bd6e440 100644
--- a/drivers/mmc/core/sdio_uart.c
+++ b/drivers/mmc/core/sdio_uart.c
@@ -250,21 +250,7 @@  static void sdio_uart_change_speed(struct sdio_uart_port *port,
 	unsigned char cval, fcr = 0;
 	unsigned int baud, quot;
 
-	switch (termios->c_cflag & CSIZE) {
-	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;
-	}
+	cval = UART_LCR_WLEN(tty_get_char_size(termios->c_cflag));
 
 	if (termios->c_cflag & CSTOPB)
 		cval |= UART_LCR_STOP;