All of lore.kernel.org
 help / color / mirror / Atom feed
* amba-pl011 driver: bug in RS485 mode
@ 2021-12-27  8:36 Jochen Mades
  2021-12-30 12:21 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Jochen Mades @ 2021-12-27  8:36 UTC (permalink / raw)
  To: Greg KH, linux-serial@vger.kernel.org, Lino Sanfilippo

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.

Bests
Jochen

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: amba-pl011 driver: bug in RS485 mode
  2021-12-27  8:36 amba-pl011 driver: bug in RS485 mode Jochen Mades
@ 2021-12-30 12:21 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2021-12-30 12:21 UTC (permalink / raw)
  To: Jochen Mades; +Cc: linux-serial@vger.kernel.org, Lino Sanfilippo

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-30 12:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-27  8:36 amba-pl011 driver: bug in RS485 mode Jochen Mades
2021-12-30 12:21 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.