[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGm1_ksBaEN0OWR+dTwT9SgoybtnchcCKasjXf5ybP2fZfRF7A@mail.gmail.com>
Date: Sun, 6 Oct 2019 13:21:03 +0200
From: Yegor Yefremov <yegorslists@...glemail.com>
To: Adam Ford <aford173@...il.com>
Cc: linux-serial@...r.kernel.org, adam.ford@...icpd.com,
Linux-OMAP <linux-omap@...r.kernel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jslaby@...e.com>, Vignesh R <vigneshr@...com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Tony Lindgren <tony@...mide.com>,
Douglas Anderson <dianders@...omium.org>,
kernel list <linux-kernel@...r.kernel.org>,
Nuno Gonçalves <nunojpg@...il.com>,
Giulio Benetti <giulio.benetti@...ettiengineering.com>,
Stefan Roese <sr@...x.de>
Subject: Re: [PATCH] serial: 8250_omap: Fix gpio check for auto RTS and CTS
Hi Adam,
On Sun, Oct 6, 2019 at 4:33 AM Adam Ford <aford173@...il.com> wrote:
>
> There are two checks to see if the manual gpio is configured, but
> these the check is seeing if the structure is NULL instead it
> should check to see if there are CTS and/or RTS pins defined.
>
> This patch uses checks for those individual pins instead of
> checking for the structure itself.
>
> Signed-off-by: Adam Ford <aford173@...il.com>
>
> diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
> index c68e2b3a1634..836e736ae188 100644
> --- a/drivers/tty/serial/8250/8250_omap.c
> +++ b/drivers/tty/serial/8250/8250_omap.c
> @@ -141,7 +141,7 @@ static void omap8250_set_mctrl(struct uart_port *port, unsigned int mctrl)
>
> serial8250_do_set_mctrl(port, mctrl);
>
> - if (!up->gpios) {
> + if (!mctrl_gpio_to_gpiod(up->gpios, UART_GPIO_RTS)) {
> /*
> * Turn off autoRTS if RTS is lowered and restore autoRTS
> * setting if RTS is raised
> @@ -456,7 +456,8 @@ static void omap_8250_set_termios(struct uart_port *port,
> up->port.status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS | UPSTAT_AUTOXOFF);
>
> if (termios->c_cflag & CRTSCTS && up->port.flags & UPF_HARD_FLOW &&
> - !up->gpios) {
> + !mctrl_gpio_to_gpiod(up->gpios, UART_GPIO_RTS) &&
> + !mctrl_gpio_to_gpiod(up->gpios, UART_GPIO_CTS)) {
> /* Enable AUTOCTS (autoRTS is enabled when RTS is raised) */
> up->port.status |= UPSTAT_AUTOCTS | UPSTAT_AUTORTS;
> priv->efr |= UART_EFR_CTS;
Looks good to me but !up->gpios must remain as otherwise, we will get
NULL pointer dereference. What do you think?
Also adding some more people who can be interested in testing this approach.
Cheers,
Yegor
Powered by blists - more mailing lists