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 |
> -----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
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 --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; }