diff mbox series

[1/1] gpio: mxc: use platform_get_irq_optional() to avoid error message

Message ID 20230508194555.1057007-1-shenwei.wang@nxp.com
State New
Headers show
Series [1/1] gpio: mxc: use platform_get_irq_optional() to avoid error message | expand

Commit Message

Shenwei Wang May 8, 2023, 7:45 p.m. UTC
From: Fugang Duan <fugang.duan@nxp.com>

Use platform_get_irq_optional() to avoid error message for the
optional irq.

Fixes: 7723f4c5ecdb ("driver core: platform: Add an error message to platform_get_irq*()")
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
---
 drivers/gpio/gpio-mxc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Shenwei Wang May 9, 2023, 3:31 p.m. UTC | #1
> -----Original Message-----
> From: Andy Shevchenko <andy.shevchenko@gmail.com>
> Sent: Tuesday, May 9, 2023 4:12 AM
> To: Shenwei Wang <shenwei.wang@nxp.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>; Bartosz Golaszewski
> <brgl@bgdev.pl>; Greg Kroah-Hartman <gregkh@linuxfoundation.org>; Stephen
> Boyd <swboyd@chromium.org>; Rafael J. Wysocki
> <rafael.j.wysocki@intel.com>; linux-gpio@vger.kernel.org; imx@lists.linux.dev;
> dl-linux-imx <linux-imx@nxp.com>; Fugang Duan <fugang.duan@nxp.com>
> Subject: [EXT] Re: [PATCH 1/1] gpio: mxc: use platform_get_irq_optional() to
> avoid error message
> 
> Caution: This is an external email. Please take care when clicking links or
> opening attachments. When in doubt, report the message using the 'Report this
> email' button
> 
> 
> On Mon, May 8, 2023 at 10:46 PM Shenwei Wang <shenwei.wang@nxp.com>
> wrote:
> >
> > From: Fugang Duan <fugang.duan@nxp.com>
> >
> > Use platform_get_irq_optional() to avoid error message for the
> 
> an error
> 
> > optional irq.
> 
> ...
> 
> >         if (irq_count > 1) {
> > -               port->irq_high = platform_get_irq(pdev, 1);
> > +               port->irq_high = platform_get_irq_optional(pdev, 1);
> >                 if (port->irq_high < 0)
> >                         port->irq_high = 0;
> 
> I would rather do
> 
>   err = platform_get_irq_optional(pdev, 1);
>   if (err >= 0)

Should be "if (err > 0)", right? As the platform_get_irq_optional() return non-zero
IRQ number on success.

Regards,
Shenwei

>     port->irq_high = err;
> 
> >         }
> 
> And looking into the code the above piece makes more sense after asking for
> the first (mandatory) IRQ.
> 
> --
> With Best Regards,
> Andy Shevchenko
Andy Shevchenko May 9, 2023, 3:41 p.m. UTC | #2
On Tue, May 9, 2023 at 6:31 PM Shenwei Wang <shenwei.wang@nxp.com> wrote:
> > From: Andy Shevchenko <andy.shevchenko@gmail.com>
> > Sent: Tuesday, May 9, 2023 4:12 AM
> > On Mon, May 8, 2023 at 10:46 PM Shenwei Wang <shenwei.wang@nxp.com>
> > wrote:

...

> > >         if (irq_count > 1) {
> > > -               port->irq_high = platform_get_irq(pdev, 1);
> > > +               port->irq_high = platform_get_irq_optional(pdev, 1);
> > >                 if (port->irq_high < 0)
> > >                         port->irq_high = 0;
> >
> > I would rather do
> >
> >   err = platform_get_irq_optional(pdev, 1);
> >   if (err >= 0)
>
> Should be "if (err > 0)", right? As the platform_get_irq_optional() return non-zero
> IRQ number on success.

Either way will work, but your proposal is better.

> >     port->irq_high = err;
> >
> > >         }
> >
> > And looking into the code the above piece makes more sense after asking for
> > the first (mandatory) IRQ.
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
index 9d0cec4b82a3..aa5a9c25e415 100644
--- a/drivers/gpio/gpio-mxc.c
+++ b/drivers/gpio/gpio-mxc.c
@@ -406,7 +406,7 @@  static int mxc_gpio_probe(struct platform_device *pdev)
 		return irq_count;
 
 	if (irq_count > 1) {
-		port->irq_high = platform_get_irq(pdev, 1);
+		port->irq_high = platform_get_irq_optional(pdev, 1);
 		if (port->irq_high < 0)
 			port->irq_high = 0;
 	}