Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1640511 > unrolled thread

[PATCH V2] serial: efm32: Fix parity management in 'efm32_uart_console_get_options()'

Started byChristophe JAILLET <christophe.jaillet@wanadoo.fr>
First post2017-05-12 16:40 +0200
Last post2017-05-12 22:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH V2] serial: efm32: Fix parity management in 'efm32_uart_console_get_options()' Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-05-12 16:40 +0200
    Re: [PATCH V2] serial: efm32: Fix parity management in  'efm32_uart_console_get_options()' Uwe Kleine-König          <u.kleine-koenig@pengutronix.de> - 2017-05-12 22:20 +0200

#1640511 — [PATCH V2] serial: efm32: Fix parity management in 'efm32_uart_console_get_options()'

FromChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Date2017-05-12 16:40 +0200
Subject[PATCH V2] serial: efm32: Fix parity management in 'efm32_uart_console_get_options()'
Message-ID<tGjTz-5TF-1@gated-at.bofh.it>
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: 3afbd89c9639 ("serial/efm32: add new driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
v2: Add UARTn_FRAME_PARITY__MASK
    Test the 2 parity bits in the EVEN case

v1 and related comment are quite old and can be found at:
   http://marc.info/?t=148676095800005&r=1&w=4
I also added a __MASK to the proposed constant name to be consistent with
UARTn_FRAME_DATABITS__MASK
---
 drivers/tty/serial/efm32-uart.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/efm32-uart.c b/drivers/tty/serial/efm32-uart.c
index ebd8569f9ad5..9fff25be87f9 100644
--- a/drivers/tty/serial/efm32-uart.c
+++ b/drivers/tty/serial/efm32-uart.c
@@ -27,6 +27,7 @@
 #define UARTn_FRAME		0x04
 #define UARTn_FRAME_DATABITS__MASK	0x000f
 #define UARTn_FRAME_DATABITS(n)		((n) - 3)
+#define UARTn_FRAME_PARITY__MASK	0x0300
 #define UARTn_FRAME_PARITY_NONE		0x0000
 #define UARTn_FRAME_PARITY_EVEN		0x0200
 #define UARTn_FRAME_PARITY_ODD		0x0300
@@ -572,12 +573,16 @@ static void efm32_uart_console_get_options(struct efm32_uart_port *efm_port,
 			16 * (4 + (clkdiv >> 6)));
 
 	frame = efm32_uart_read32(efm_port, UARTn_FRAME);
-	if (frame & UARTn_FRAME_PARITY_ODD)
+	switch (frame & UARTn_FRAME_PARITY__MASK) {
+	case UARTn_FRAME_PARITY_ODD:
 		*parity = 'o';
-	else if (frame & UARTn_FRAME_PARITY_EVEN)
+		break;
+	case UARTn_FRAME_PARITY_EVEN:
 		*parity = 'e';
-	else
+		break;
+	default:
 		*parity = 'n';
+	}
 
 	*bits = (frame & UARTn_FRAME_DATABITS__MASK) -
 			UARTn_FRAME_DATABITS(4) + 4;
-- 
2.11.0

[toc] | [next] | [standalone]


#1640724 — Re: [PATCH V2] serial: efm32: Fix parity management in 'efm32_uart_console_get_options()'

FromUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date2017-05-12 22:20 +0200
SubjectRe: [PATCH V2] serial: efm32: Fix parity management in 'efm32_uart_console_get_options()'
Message-ID<tGpcB-1r5-3@gated-at.bofh.it>
In reply to#1640511
On Fri, May 12, 2017 at 04:35:45PM +0200, Christophe JAILLET wrote:
> 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: 3afbd89c9639 ("serial/efm32: add new driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Thanks for picking this topic up again.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web