[1/3] serial: atmel: Don't check for mctrl_gpio_to_gpiod() returning error
diff mbox series

Message ID 20190814092924.13857-2-geert+renesas@glider.be
State Under Review
Delegated to: Geert Uytterhoeven
Headers show
Series
  • [1/3] serial: atmel: Don't check for mctrl_gpio_to_gpiod() returning error
Related show

Commit Message

Geert Uytterhoeven Aug. 14, 2019, 9:29 a.m. UTC
Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
routine"), mctrl_gpio_init() returns failure if the assignment to any
member of the gpio array results in an error pointer.
Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
!CONFIG_GPIOLIB case.
Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
returning an error value.  A simple NULL check is sufficient.

This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/tty/serial/atmel_serial.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Uwe Kleine-König Aug. 14, 2019, 9:35 a.m. UTC | #1
Hello,

[adding the Atmel guys to Cc]

On Wed, Aug 14, 2019 at 11:29:22AM +0200, Geert Uytterhoeven wrote:
> Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
> routine"), mctrl_gpio_init() returns failure if the assignment to any
> member of the gpio array results in an error pointer.
> Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
> in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
> !CONFIG_GPIOLIB case.
> Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
> returning an error value.  A simple NULL check is sufficient.
> 
> This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
> drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
>  drivers/tty/serial/atmel_serial.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index 19a85d6fe3d20541..e9620a81166b7dc1 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -303,32 +303,28 @@ static unsigned int atmel_get_lines_status(struct uart_port *port)
>  
>  	mctrl_gpio_get(atmel_port->gpios, &ret);
>  
> -	if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
> -						UART_GPIO_CTS))) {
> +	if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
>  		if (ret & TIOCM_CTS)
>  			status &= ~ATMEL_US_CTS;
>  		else
>  			status |= ATMEL_US_CTS;
>  	}

The change is fine, but it seems the atmel driver doesn't use mctrl_gpio
as expected (at least as expected by me). IMHO driving the hardware
function of the CTS pin shouldn't be conditional on the presence of a
cts-gpio. Is there a reason not to just drop the if completely?

Best regards
Uwe
Geert Uytterhoeven Aug. 14, 2019, 10:20 a.m. UTC | #2
Hi Uwe,

On Wed, Aug 14, 2019 at 11:36 AM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> On Wed, Aug 14, 2019 at 11:29:22AM +0200, Geert Uytterhoeven wrote:
> > Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
> > routine"), mctrl_gpio_init() returns failure if the assignment to any
> > member of the gpio array results in an error pointer.
> > Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
> > in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
> > !CONFIG_GPIOLIB case.
> > Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
> > returning an error value.  A simple NULL check is sufficient.
> >
> > This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
> > drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.
> >
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > ---
> >  drivers/tty/serial/atmel_serial.c | 12 ++++--------
> >  1 file changed, 4 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> > index 19a85d6fe3d20541..e9620a81166b7dc1 100644
> > --- a/drivers/tty/serial/atmel_serial.c
> > +++ b/drivers/tty/serial/atmel_serial.c
> > @@ -303,32 +303,28 @@ static unsigned int atmel_get_lines_status(struct uart_port *port)
> >
> >       mctrl_gpio_get(atmel_port->gpios, &ret);
> >
> > -     if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
> > -                                             UART_GPIO_CTS))) {
> > +     if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
> >               if (ret & TIOCM_CTS)
> >                       status &= ~ATMEL_US_CTS;
> >               else
> >                       status |= ATMEL_US_CTS;
> >       }
>
> The change is fine, but it seems the atmel driver doesn't use mctrl_gpio
> as expected (at least as expected by me). IMHO driving the hardware
> function of the CTS pin shouldn't be conditional on the presence of a
> cts-gpio. Is there a reason not to just drop the if completely?

The above code returns the hardware status if CTS is not a GPIO, and
returns (overrides with) the GPIO status if CTS is a GPIO.
Isn't that correct, or am I missing something?

Gr{oetje,eeting}s,

                        Geert
Uwe Kleine-König Aug. 14, 2019, 11:08 a.m. UTC | #3
On Wed, Aug 14, 2019 at 12:20:33PM +0200, Geert Uytterhoeven wrote:
> Hi Uwe,
> 
> On Wed, Aug 14, 2019 at 11:36 AM Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
> > On Wed, Aug 14, 2019 at 11:29:22AM +0200, Geert Uytterhoeven wrote:
> > > Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
> > > routine"), mctrl_gpio_init() returns failure if the assignment to any
> > > member of the gpio array results in an error pointer.
> > > Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
> > > in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
> > > !CONFIG_GPIOLIB case.
> > > Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
> > > returning an error value.  A simple NULL check is sufficient.
> > >
> > > This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
> > > drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.
> > >
> > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > ---
> > >  drivers/tty/serial/atmel_serial.c | 12 ++++--------
> > >  1 file changed, 4 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> > > index 19a85d6fe3d20541..e9620a81166b7dc1 100644
> > > --- a/drivers/tty/serial/atmel_serial.c
> > > +++ b/drivers/tty/serial/atmel_serial.c
> > > @@ -303,32 +303,28 @@ static unsigned int atmel_get_lines_status(struct uart_port *port)
> > >
> > >       mctrl_gpio_get(atmel_port->gpios, &ret);
> > >
> > > -     if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
> > > -                                             UART_GPIO_CTS))) {
> > > +     if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
> > >               if (ret & TIOCM_CTS)
> > >                       status &= ~ATMEL_US_CTS;
> > >               else
> > >                       status |= ATMEL_US_CTS;
> > >       }
> >
> > The change is fine, but it seems the atmel driver doesn't use mctrl_gpio
> > as expected (at least as expected by me). IMHO driving the hardware
> > function of the CTS pin shouldn't be conditional on the presence of a
> > cts-gpio. Is there a reason not to just drop the if completely?
> 
> The above code returns the hardware status if CTS is not a GPIO, and
> returns (overrides with) the GPIO status if CTS is a GPIO.
> Isn't that correct, or am I missing something?

I took a deeper look into this driver now. The task for
atmel_get_lines_status() isn't to implement the get_mctrl() callback.

Instead this is called in the irqhandler to set ATMEL_US_RI in a
"pending" value that then later in atmel_handle_status() is translated
to a "ring" event that is handled there.

So the right cleanup would be to let atmel_get_lines_status() just be

	return atmel_uart_readl(port, ATMEL_US_CSR);

. If something happend on the lines implemented as gpio the driver's irq
function isn't called anyhow.

Best regards
Uwe
Richard Genoud Aug. 20, 2019, 3:11 p.m. UTC | #4
Hi,
Le 14/08/2019 à 12:20, Geert Uytterhoeven a écrit :
> Hi Uwe,
> 
> On Wed, Aug 14, 2019 at 11:36 AM Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
>> On Wed, Aug 14, 2019 at 11:29:22AM +0200, Geert Uytterhoeven wrote:
>>> Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
>>> routine"), mctrl_gpio_init() returns failure if the assignment to any
>>> member of the gpio array results in an error pointer.
>>> Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
>>> in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
>>> !CONFIG_GPIOLIB case.
>>> Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
>>> returning an error value.  A simple NULL check is sufficient.
>>>
>>> This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
>>> drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.
>>>
>>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>>> ---
>>>  drivers/tty/serial/atmel_serial.c | 12 ++++--------
>>>  1 file changed, 4 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
>>> index 19a85d6fe3d20541..e9620a81166b7dc1 100644
>>> --- a/drivers/tty/serial/atmel_serial.c
>>> +++ b/drivers/tty/serial/atmel_serial.c
>>> @@ -303,32 +303,28 @@ static unsigned int atmel_get_lines_status(struct uart_port *port)
>>>
>>>       mctrl_gpio_get(atmel_port->gpios, &ret);
>>>
>>> -     if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
>>> -                                             UART_GPIO_CTS))) {
>>> +     if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
>>>               if (ret & TIOCM_CTS)
>>>                       status &= ~ATMEL_US_CTS;
>>>               else
>>>                       status |= ATMEL_US_CTS;
>>>       }
>>
>> The change is fine, but it seems the atmel driver doesn't use mctrl_gpio
>> as expected (at least as expected by me). IMHO driving the hardware
>> function of the CTS pin shouldn't be conditional on the presence of a
>> cts-gpio. Is there a reason not to just drop the if completely?
> 
> The above code returns the hardware status if CTS is not a GPIO, and
> returns (overrides with) the GPIO status if CTS is a GPIO.
> Isn't that correct, or am I missing something?
Yes, that's correct.
Richard Genoud Aug. 20, 2019, 3:47 p.m. UTC | #5
Le 14/08/2019 à 13:08, Uwe Kleine-König a écrit :
> On Wed, Aug 14, 2019 at 12:20:33PM +0200, Geert Uytterhoeven wrote:
>> Hi Uwe,
>>
>> On Wed, Aug 14, 2019 at 11:36 AM Uwe Kleine-König
>> <u.kleine-koenig@pengutronix.de> wrote:
>>> On Wed, Aug 14, 2019 at 11:29:22AM +0200, Geert Uytterhoeven wrote:
>>>> Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
>>>> routine"), mctrl_gpio_init() returns failure if the assignment to any
>>>> member of the gpio array results in an error pointer.
>>>> Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
>>>> in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
>>>> !CONFIG_GPIOLIB case.
>>>> Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
>>>> returning an error value.  A simple NULL check is sufficient.
>>>>
>>>> This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
>>>> drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.
>>>>
>>>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>>>> ---
>>>>  drivers/tty/serial/atmel_serial.c | 12 ++++--------
>>>>  1 file changed, 4 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
>>>> index 19a85d6fe3d20541..e9620a81166b7dc1 100644
>>>> --- a/drivers/tty/serial/atmel_serial.c
>>>> +++ b/drivers/tty/serial/atmel_serial.c
>>>> @@ -303,32 +303,28 @@ static unsigned int atmel_get_lines_status(struct uart_port *port)
>>>>
>>>>       mctrl_gpio_get(atmel_port->gpios, &ret);
>>>>
>>>> -     if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
>>>> -                                             UART_GPIO_CTS))) {
>>>> +     if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
>>>>               if (ret & TIOCM_CTS)
>>>>                       status &= ~ATMEL_US_CTS;
>>>>               else
>>>>                       status |= ATMEL_US_CTS;
>>>>       }
>>>
>>> The change is fine, but it seems the atmel driver doesn't use mctrl_gpio
>>> as expected (at least as expected by me). IMHO driving the hardware
>>> function of the CTS pin shouldn't be conditional on the presence of a
>>> cts-gpio. Is there a reason not to just drop the if completely?
>>
>> The above code returns the hardware status if CTS is not a GPIO, and
>> returns (overrides with) the GPIO status if CTS is a GPIO.
>> Isn't that correct, or am I missing something?
> 
> I took a deeper look into this driver now. The task for
> atmel_get_lines_status() isn't to implement the get_mctrl() callback.
> 
> Instead this is called in the irqhandler to set ATMEL_US_RI in a
> "pending" value that then later in atmel_handle_status() is translated
> to a "ring" event that is handled there.
> 
> So the right cleanup would be to let atmel_get_lines_status() just be
> 
> 	return atmel_uart_readl(port, ATMEL_US_CSR);
> 
> . If something happend on the lines implemented as gpio the driver's irq
> function isn't called anyhow.

I'd like to give it a good test to be sure, and I'll get back to you.

Thanks,
Richard
Richard Genoud Aug. 21, 2019, 3:27 p.m. UTC | #6
Le 20/08/2019 à 17:47, Richard Genoud a écrit :
> Le 14/08/2019 à 13:08, Uwe Kleine-König a écrit :
>> On Wed, Aug 14, 2019 at 12:20:33PM +0200, Geert Uytterhoeven wrote:
>>> Hi Uwe,
>>>
>>> On Wed, Aug 14, 2019 at 11:36 AM Uwe Kleine-König
>>> <u.kleine-koenig@pengutronix.de> wrote:
>>>> On Wed, Aug 14, 2019 at 11:29:22AM +0200, Geert Uytterhoeven wrote:
>>>>> Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
>>>>> routine"), mctrl_gpio_init() returns failure if the assignment to any
>>>>> member of the gpio array results in an error pointer.
>>>>> Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
>>>>> in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
>>>>> !CONFIG_GPIOLIB case.
>>>>> Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
>>>>> returning an error value.  A simple NULL check is sufficient.
>>>>>
>>>>> This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
>>>>> drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.
>>>>>
>>>>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>>>>> ---
>>>>>  drivers/tty/serial/atmel_serial.c | 12 ++++--------
>>>>>  1 file changed, 4 insertions(+), 8 deletions(-)
>>>>>
>>>>> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
>>>>> index 19a85d6fe3d20541..e9620a81166b7dc1 100644
>>>>> --- a/drivers/tty/serial/atmel_serial.c
>>>>> +++ b/drivers/tty/serial/atmel_serial.c
>>>>> @@ -303,32 +303,28 @@ static unsigned int atmel_get_lines_status(struct uart_port *port)
>>>>>
>>>>>       mctrl_gpio_get(atmel_port->gpios, &ret);
>>>>>
>>>>> -     if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
>>>>> -                                             UART_GPIO_CTS))) {
>>>>> +     if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
>>>>>               if (ret & TIOCM_CTS)
>>>>>                       status &= ~ATMEL_US_CTS;
>>>>>               else
>>>>>                       status |= ATMEL_US_CTS;
>>>>>       }
>>>>
>>>> The change is fine, but it seems the atmel driver doesn't use mctrl_gpio
>>>> as expected (at least as expected by me). IMHO driving the hardware
>>>> function of the CTS pin shouldn't be conditional on the presence of a
>>>> cts-gpio. Is there a reason not to just drop the if completely?
>>>
>>> The above code returns the hardware status if CTS is not a GPIO, and
>>> returns (overrides with) the GPIO status if CTS is a GPIO.
>>> Isn't that correct, or am I missing something?
>>
>> I took a deeper look into this driver now. The task for
>> atmel_get_lines_status() isn't to implement the get_mctrl() callback.
>>
>> Instead this is called in the irqhandler to set ATMEL_US_RI in a
>> "pending" value that then later in atmel_handle_status() is translated
>> to a "ring" event that is handled there.
>>
>> So the right cleanup would be to let atmel_get_lines_status() just be
>>
>> 	return atmel_uart_readl(port, ATMEL_US_CSR);
>>
>> . If something happend on the lines implemented as gpio the driver's irq
>> function isn't called anyhow.
> 
> I'd like to give it a good test to be sure, and I'll get back to you.

So, Uwe is right.
Since commit ce59e48fdbad ("serial: mctrl_gpio: implement interrupt handling"),
atmel_get_lines_status() can be completly killed and replaced by :
atmel_uart_readl(port, ATMEL_US_CSR);

Geert, do you want to send a patch for that, or should I do it ?


Thanks,
Richard
Geert Uytterhoeven Aug. 21, 2019, 4:04 p.m. UTC | #7
Hi Richard,

On Wed, Aug 21, 2019 at 5:27 PM Richard Genoud <richard.genoud@gmail.com> wrote:
> Le 20/08/2019 à 17:47, Richard Genoud a écrit :
> > Le 14/08/2019 à 13:08, Uwe Kleine-König a écrit :
> >> On Wed, Aug 14, 2019 at 12:20:33PM +0200, Geert Uytterhoeven wrote:
> >>> Hi Uwe,
> >>>
> >>> On Wed, Aug 14, 2019 at 11:36 AM Uwe Kleine-König
> >>> <u.kleine-koenig@pengutronix.de> wrote:
> >>>> On Wed, Aug 14, 2019 at 11:29:22AM +0200, Geert Uytterhoeven wrote:
> >>>>> Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
> >>>>> routine"), mctrl_gpio_init() returns failure if the assignment to any
> >>>>> member of the gpio array results in an error pointer.
> >>>>> Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
> >>>>> in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
> >>>>> !CONFIG_GPIOLIB case.
> >>>>> Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
> >>>>> returning an error value.  A simple NULL check is sufficient.
> >>>>>
> >>>>> This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
> >>>>> drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.
> >>>>>
> >>>>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> >>>>> ---
> >>>>>  drivers/tty/serial/atmel_serial.c | 12 ++++--------
> >>>>>  1 file changed, 4 insertions(+), 8 deletions(-)
> >>>>>
> >>>>> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> >>>>> index 19a85d6fe3d20541..e9620a81166b7dc1 100644
> >>>>> --- a/drivers/tty/serial/atmel_serial.c
> >>>>> +++ b/drivers/tty/serial/atmel_serial.c
> >>>>> @@ -303,32 +303,28 @@ static unsigned int atmel_get_lines_status(struct uart_port *port)
> >>>>>
> >>>>>       mctrl_gpio_get(atmel_port->gpios, &ret);
> >>>>>
> >>>>> -     if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
> >>>>> -                                             UART_GPIO_CTS))) {
> >>>>> +     if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
> >>>>>               if (ret & TIOCM_CTS)
> >>>>>                       status &= ~ATMEL_US_CTS;
> >>>>>               else
> >>>>>                       status |= ATMEL_US_CTS;
> >>>>>       }
> >>>>
> >>>> The change is fine, but it seems the atmel driver doesn't use mctrl_gpio
> >>>> as expected (at least as expected by me). IMHO driving the hardware
> >>>> function of the CTS pin shouldn't be conditional on the presence of a
> >>>> cts-gpio. Is there a reason not to just drop the if completely?
> >>>
> >>> The above code returns the hardware status if CTS is not a GPIO, and
> >>> returns (overrides with) the GPIO status if CTS is a GPIO.
> >>> Isn't that correct, or am I missing something?
> >>
> >> I took a deeper look into this driver now. The task for
> >> atmel_get_lines_status() isn't to implement the get_mctrl() callback.
> >>
> >> Instead this is called in the irqhandler to set ATMEL_US_RI in a
> >> "pending" value that then later in atmel_handle_status() is translated
> >> to a "ring" event that is handled there.
> >>
> >> So the right cleanup would be to let atmel_get_lines_status() just be
> >>
> >>      return atmel_uart_readl(port, ATMEL_US_CSR);
> >>
> >> . If something happend on the lines implemented as gpio the driver's irq
> >> function isn't called anyhow.
> >
> > I'd like to give it a good test to be sure, and I'll get back to you.
>
> So, Uwe is right.
> Since commit ce59e48fdbad ("serial: mctrl_gpio: implement interrupt handling"),
> atmel_get_lines_status() can be completly killed and replaced by :
> atmel_uart_readl(port, ATMEL_US_CSR);
>
> Geert, do you want to send a patch for that, or should I do it ?

Feel free to send a  patch.
I don't have the Atmel hardware  anyway.
Thanks!

Gr{oetje,eeting}s,

                        Geert

Patch
diff mbox series

diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 19a85d6fe3d20541..e9620a81166b7dc1 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -303,32 +303,28 @@  static unsigned int atmel_get_lines_status(struct uart_port *port)
 
 	mctrl_gpio_get(atmel_port->gpios, &ret);
 
-	if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
-						UART_GPIO_CTS))) {
+	if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
 		if (ret & TIOCM_CTS)
 			status &= ~ATMEL_US_CTS;
 		else
 			status |= ATMEL_US_CTS;
 	}
 
-	if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
-						UART_GPIO_DSR))) {
+	if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_DSR)) {
 		if (ret & TIOCM_DSR)
 			status &= ~ATMEL_US_DSR;
 		else
 			status |= ATMEL_US_DSR;
 	}
 
-	if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
-						UART_GPIO_RI))) {
+	if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_RI)) {
 		if (ret & TIOCM_RI)
 			status &= ~ATMEL_US_RI;
 		else
 			status |= ATMEL_US_RI;
 	}
 
-	if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
-						UART_GPIO_DCD))) {
+	if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_DCD)) {
 		if (ret & TIOCM_CD)
 			status &= ~ATMEL_US_DCD;
 		else