return 0;
 }
 
-static unsigned long
-stm32_get_char(struct uart_port *port, u32 *sr, int *last_res)
+static unsigned long stm32_get_char(struct uart_port *port, u32 *sr,
+                                   int *last_res)
 {
        struct stm32_port *stm32_port = to_stm32_port(port);
        struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
                c = stm32_port->rx_buf[RX_BUF_L - (*last_res)--];
                if ((*last_res) == 0)
                        *last_res = RX_BUF_L;
-               return c;
        } else {
-               return readl_relaxed(port->membase + ofs->rdr);
+               c = readl_relaxed(port->membase + ofs->rdr);
+               /* apply RDR data mask */
+               c &= stm32_port->rdr_mask;
        }
+
+       return c;
 }
 
 static void stm32_receive_chars(struct uart_port *port, bool threaded)
                cr2 |= USART_CR2_STOP_2B;
 
        bits = stm32_get_databits(termios);
+       stm32_port->rdr_mask = (BIT(bits) - 1);
 
        if (cflag & PARENB) {
                bits++;