Skip to content

Commit be40597

Browse files
tititiou36gregkh
authored andcommitted
serial: efm32: Fix parity management in 'efm32_uart_console_get_options()'
UARTn_FRAME_PARITY_ODD is 0x0300 UARTn_FRAME_PARITY_EVEN is 0x0200 So if the UART is configured for EVEN parity, it would be reported as ODD. Fix it by correctly testing if the 2 bits are set. Fixes: 3afbd89 ("serial/efm32: add new driver") Signed-off-by: Christophe JAILLET <[email protected]> Acked-by: Uwe Kleine-König <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent aee5da7 commit be40597

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/tty/serial/efm32-uart.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define UARTn_FRAME 0x04
2828
#define UARTn_FRAME_DATABITS__MASK 0x000f
2929
#define UARTn_FRAME_DATABITS(n) ((n) - 3)
30+
#define UARTn_FRAME_PARITY__MASK 0x0300
3031
#define UARTn_FRAME_PARITY_NONE 0x0000
3132
#define UARTn_FRAME_PARITY_EVEN 0x0200
3233
#define UARTn_FRAME_PARITY_ODD 0x0300
@@ -572,12 +573,16 @@ static void efm32_uart_console_get_options(struct efm32_uart_port *efm_port,
572573
16 * (4 + (clkdiv >> 6)));
573574

574575
frame = efm32_uart_read32(efm_port, UARTn_FRAME);
575-
if (frame & UARTn_FRAME_PARITY_ODD)
576+
switch (frame & UARTn_FRAME_PARITY__MASK) {
577+
case UARTn_FRAME_PARITY_ODD:
576578
*parity = 'o';
577-
else if (frame & UARTn_FRAME_PARITY_EVEN)
579+
break;
580+
case UARTn_FRAME_PARITY_EVEN:
578581
*parity = 'e';
579-
else
582+
break;
583+
default:
580584
*parity = 'n';
585+
}
581586

582587
*bits = (frame & UARTn_FRAME_DATABITS__MASK) -
583588
UARTn_FRAME_DATABITS(4) + 4;

0 commit comments

Comments
 (0)