GPIO IRQ setup can fail either because an invalid IRQ was passed as a
parameter, or because the GPIO controller does not support interrupts.
Neither is severe enough to stop the whole probe; simply disable IRQ
support in the GPIO resource when setup fails.
Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---
v2: no changes (was patch 3/4)
drivers/mfd/tqmx86.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/mfd/tqmx86.c b/drivers/mfd/tqmx86.c
index 5aa51ead00a28..7f9ccd83278dd 100644
--- a/drivers/mfd/tqmx86.c
+++ b/drivers/mfd/tqmx86.c
@@ -259,13 +259,14 @@ static int tqmx86_probe(struct platform_device *pdev)
err = tqmx86_setup_irq(dev, "GPIO", gpio_irq, io_base,
TQMX86_REG_IO_EXT_INT_GPIO_SHIFT);
if (err)
- return err;
+ gpio_irq = 0;
+ }
+ if (gpio_irq)
/* Assumes the IRQ resource is first. */
tqmx_gpio_resources[0].start = gpio_irq;
- } else {
+ else
tqmx_gpio_resources[0].flags = 0;
- }
ocores_platform_data.clock_khz = tqmx86_board_id_to_clk_rate(dev, board_id);
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/
On Mon, 17 Jun 2024, Matthias Schiffer wrote:
> GPIO IRQ setup can fail either because an invalid IRQ was passed as a
> parameter, or because the GPIO controller does not support interrupts.
> Neither is severe enough to stop the whole probe; simply disable IRQ
> support in the GPIO resource when setup fails.
>
> Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
> ---
>
> v2: no changes (was patch 3/4)
>
> drivers/mfd/tqmx86.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mfd/tqmx86.c b/drivers/mfd/tqmx86.c
> index 5aa51ead00a28..7f9ccd83278dd 100644
> --- a/drivers/mfd/tqmx86.c
> +++ b/drivers/mfd/tqmx86.c
> @@ -259,13 +259,14 @@ static int tqmx86_probe(struct platform_device *pdev)
> err = tqmx86_setup_irq(dev, "GPIO", gpio_irq, io_base,
> TQMX86_REG_IO_EXT_INT_GPIO_SHIFT);
> if (err)
> - return err;
> + gpio_irq = 0;
> + }
>
> + if (gpio_irq)
Stacking identical if()s one after another doesn't sound very efficient.
Why not put the contents of this one inside the one above?
> /* Assumes the IRQ resource is first. */
> tqmx_gpio_resources[0].start = gpio_irq;
> - } else {
> + else
> tqmx_gpio_resources[0].flags = 0;
> - }
>
> ocores_platform_data.clock_khz = tqmx86_board_id_to_clk_rate(dev, board_id);
>
> --
> TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
> Amtsgericht München, HRB 105018
> Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
> https://www.tq-group.com/
>
--
Lee Jones [李琼斯]
On Thu, 2024-06-20 at 17:35 +0100, Lee Jones wrote:
>
> On Mon, 17 Jun 2024, Matthias Schiffer wrote:
>
> > GPIO IRQ setup can fail either because an invalid IRQ was passed as a
> > parameter, or because the GPIO controller does not support interrupts.
> > Neither is severe enough to stop the whole probe; simply disable IRQ
> > support in the GPIO resource when setup fails.
> >
> > Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
> > ---
> >
> > v2: no changes (was patch 3/4)
> >
> > drivers/mfd/tqmx86.c | 7 ++++---
> > 1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/mfd/tqmx86.c b/drivers/mfd/tqmx86.c
> > index 5aa51ead00a28..7f9ccd83278dd 100644
> > --- a/drivers/mfd/tqmx86.c
> > +++ b/drivers/mfd/tqmx86.c
> > @@ -259,13 +259,14 @@ static int tqmx86_probe(struct platform_device *pdev)
> > err = tqmx86_setup_irq(dev, "GPIO", gpio_irq, io_base,
> > TQMX86_REG_IO_EXT_INT_GPIO_SHIFT);
> > if (err)
> > - return err;
> > + gpio_irq = 0;
> > + }
> >
> > + if (gpio_irq)
>
> Stacking identical if()s one after another doesn't sound very efficient.
>
> Why not put the contents of this one inside the one above?
The intention was to have the "else" branch be executed both when gpio_irq was reset to 0 in the
above error path, and when gpio_irq was 0 in the first place (so the above section running
tqmx86_setup_irq() hasn't even been executed).
I got a better idea now however - by initializing flags to 0 and only setting it together with the
IRQ in the success path, no (!gpio_irq) branch is needed here at all. Will change in v3.
Best regards,
Matthias
>
> > /* Assumes the IRQ resource is first. */
> > tqmx_gpio_resources[0].start = gpio_irq;
> > - } else {
> > + else
> > tqmx_gpio_resources[0].flags = 0;
> > - }
> >
> > ocores_platform_data.clock_khz = tqmx86_board_id_to_clk_rate(dev, board_id);
> >
> > --
> > TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
> > Amtsgericht München, HRB 105018
> > Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
> > https://www.tq-group.com/
> >
>
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/
On Mon, 24 Jun 2024, Matthias Schiffer wrote: > On Thu, 2024-06-20 at 17:35 +0100, Lee Jones wrote: > > > > On Mon, 17 Jun 2024, Matthias Schiffer wrote: > > > > > GPIO IRQ setup can fail either because an invalid IRQ was passed as a > > > parameter, or because the GPIO controller does not support interrupts. > > > Neither is severe enough to stop the whole probe; simply disable IRQ > > > support in the GPIO resource when setup fails. > > > > > > Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> > > > --- > > > > > > v2: no changes (was patch 3/4) > > > > > > drivers/mfd/tqmx86.c | 7 ++++--- > > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > > > diff --git a/drivers/mfd/tqmx86.c b/drivers/mfd/tqmx86.c > > > index 5aa51ead00a28..7f9ccd83278dd 100644 > > > --- a/drivers/mfd/tqmx86.c > > > +++ b/drivers/mfd/tqmx86.c > > > @@ -259,13 +259,14 @@ static int tqmx86_probe(struct platform_device *pdev) > > > err = tqmx86_setup_irq(dev, "GPIO", gpio_irq, io_base, > > > TQMX86_REG_IO_EXT_INT_GPIO_SHIFT); > > > if (err) > > > - return err; > > > + gpio_irq = 0; > > > + } > > > > > > + if (gpio_irq) > > > > Stacking identical if()s one after another doesn't sound very efficient. > > > > Why not put the contents of this one inside the one above? > > The intention was to have the "else" branch be executed both when gpio_irq was reset to 0 in the > above error path, and when gpio_irq was 0 in the first place (so the above section running > tqmx86_setup_irq() hasn't even been executed). > > I got a better idea now however - by initializing flags to 0 and only setting it together with the > IRQ in the success path, no (!gpio_irq) branch is needed here at all. Will change in v3. That sounds like a better approach, thanks. -- Lee Jones [李琼斯]
© 2016 - 2026 Red Hat, Inc.