Skip to content

Commit 1250ed7

Browse files
Fabrice Gasniergregkh
authored andcommitted
serial: stm32: fix clearing interrupt error flags
The interrupt clear flag register is a "write 1 to clear" register. So, only writing ones allows to clear flags: - Replace buggy stm32_clr_bits() by a simple write to clear error flags - Replace useless read/modify/write stm32_set_bits() routine by a simple write to clear TC (transfer complete) flag. Fixes: 4f01d83 ("serial: stm32: fix rx error handling") Signed-off-by: Fabrice Gasnier <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent da88ac0 commit 1250ed7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/tty/serial/stm32-usart.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ static void stm32_receive_chars(struct uart_port *port, bool threaded)
240240
* cleared by the sequence [read SR - read DR].
241241
*/
242242
if ((sr & USART_SR_ERR_MASK) && ofs->icr != UNDEF_REG)
243-
stm32_clr_bits(port, ofs->icr, USART_ICR_ORECF |
244-
USART_ICR_PECF | USART_ICR_FECF);
243+
writel_relaxed(sr & USART_SR_ERR_MASK,
244+
port->membase + ofs->icr);
245245

246246
c = stm32_get_char(port, &sr, &stm32_port->last_res);
247247
port->icount.rx++;
@@ -435,7 +435,7 @@ static void stm32_transmit_chars(struct uart_port *port)
435435
if (ofs->icr == UNDEF_REG)
436436
stm32_clr_bits(port, ofs->isr, USART_SR_TC);
437437
else
438-
stm32_set_bits(port, ofs->icr, USART_ICR_TCCF);
438+
writel_relaxed(USART_ICR_TCCF, port->membase + ofs->icr);
439439

440440
if (stm32_port->tx_ch)
441441
stm32_transmit_chars_dma(port);

0 commit comments

Comments
 (0)