[PATCH] lib: utils/serial: Clear LSR status and check RBR status
Anup Patel
anup at brainfault.org
Sun Jul 20 08:14:25 PDT 2025
On Mon, Jun 16, 2025 at 3:53 PM Neo <neopimail at gmail.com> wrote:
>
> On some platforms, read RBR when it is empty may result in an error.
>
> Signed-off-by: Yi Pei <neopimail at gmail.com>
> ---
> lib/utils/serial/uart8250.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/lib/utils/serial/uart8250.c b/lib/utils/serial/uart8250.c
> index 82fb142a..ddae0aa3 100644
> --- a/lib/utils/serial/uart8250.c
> +++ b/lib/utils/serial/uart8250.c
> @@ -134,9 +134,9 @@ int uart8250_init(unsigned long base, u32 in_freq,
> u32 baudrate, u32 reg_shift,
> /* No modem control DTR RTS */
> set_reg(UART_MCR_OFFSET, 0x00);
> /* Clear line status */
> - get_reg(UART_LSR_OFFSET);
> - /* Read receive buffer */
> - get_reg(UART_RBR_OFFSET);
> + if (get_reg(UART_LSR_OFFSET) & UART_LSR_DR)
> + /* Read receive buffer */
> + get_reg(UART_RBR_OFFSET);
> /* Set scratchpad */
> set_reg(UART_SCR_OFFSET, 0x00);
> --
> 2.34.1
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
The changes in the patch are fine but I am not able to apply this
patch because it is not generated correctly. Prefer generating patch
using "git format-patch -M -C ..." and prefer sending patch using
"git send-email ..."
Reviewed-by: Anup Patel <anup at brainault.org>
I have taken care of the above patch formatting issues manually.
Applied this patch to the riscv/opensbi repo.
Regards,
Anup
More information about the opensbi
mailing list