diff mbox series

amba-pl011 driver: bug in RS485 mode

Message ID 572288095.547800.1640594185677@webmail.strato.com
State New
Headers show
Series amba-pl011 driver: bug in RS485 mode | expand

Commit Message

Jochen Mades Dec. 27, 2021, 8:36 a.m. UTC
Hi,

I tested the amba-pl011 driver from the current branch rpi-5.16.y in RS485 mode and found a bug.

The current driver pulls-up RTS in function pl011_set_mctrl independent from the rs485-flags SER_RS485_RTS_AFTER_SEND.
This leads to problems if the driver is used as RS485 slave.

In my opinion the patch should look like that (and was tested successfully by myself):


Please let me know, if I'm allowed to commit this change and let me know how to do that or if someone of you guys will do that better.

Bests
Jochen

Comments

Greg Kroah-Hartman Dec. 30, 2021, 12:21 p.m. UTC | #1
On Mon, Dec 27, 2021 at 09:36:25AM +0100, Jochen Mades wrote:
> Hi,
> 
> I tested the amba-pl011 driver from the current branch rpi-5.16.y in RS485 mode and found a bug.
> 
> The current driver pulls-up RTS in function pl011_set_mctrl independent from the rs485-flags SER_RS485_RTS_AFTER_SEND.
> This leads to problems if the driver is used as RS485 slave.
> 
> In my opinion the patch should look like that (and was tested successfully by myself):
> 
> diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
> index 537f37ac4..3b45beae8 100644
> --- a/drivers/tty/serial/amba-pl011.c
> +++ b/drivers/tty/serial/amba-pl011.c
> @@ -1647,7 +1647,12 @@ static void pl011_set_mctrl(struct uart_port *port, unsigned int mctrl)
>         unsigned int cr;
> 
>         if (port->rs485.flags & SER_RS485_ENABLED)
> -               mctrl &= ~TIOCM_RTS;
> +       {
> +               if (port->rs485.flags & SER_RS485_RTS_AFTER_SEND)
> +                       mctrl &= ~TIOCM_RTS;
> +               else
> +                       mctrl |= TIOCM_RTS;
> +       }
> 
>         cr = pl011_read(uap, REG_CR);
> 
> 
> Please let me know, if I'm allowed to commit this change and let me know how to do that or if someone of you guys will do that better.

Anyone is allowed to submit a change, please do so as per the
Documentation/SubmittingPatches file describes and we will be glad to
review it and apply it if it is ok.

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 537f37ac4..3b45beae8 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1647,7 +1647,12 @@  static void pl011_set_mctrl(struct uart_port *port, unsigned int mctrl)
        unsigned int cr;

        if (port->rs485.flags & SER_RS485_ENABLED)
-               mctrl &= ~TIOCM_RTS;
+       {
+               if (port->rs485.flags & SER_RS485_RTS_AFTER_SEND)
+                       mctrl &= ~TIOCM_RTS;
+               else
+                       mctrl |= TIOCM_RTS;
+       }

        cr = pl011_read(uap, REG_CR);