diff mbox series

[5/6] gpiolib: Fix return check of __irq_domain_alloc_irqs

Message ID 20210102175859.335447-5-adam@l4re.org
State New
Headers show
Series [1/6] irqchip/bcm2836: Fix return check in IPI alloc | expand

Commit Message

Adam Lackorzynski Jan. 2, 2021, 5:58 p.m. UTC
0 is not a proper IRQ number and also indicates failure.

Signed-off-by: Adam Lackorzynski <adam@l4re.org>
---
 drivers/gpio/gpiolib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bartosz Golaszewski Jan. 4, 2021, 1:57 p.m. UTC | #1
On Sat, Jan 2, 2021 at 6:59 PM Adam Lackorzynski <adam@l4re.org> wrote:
>
> 0 is not a proper IRQ number and also indicates failure.
>
> Signed-off-by: Adam Lackorzynski <adam@l4re.org>
> ---
>  drivers/gpio/gpiolib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index b02cc2abd3b6..9667e1a62626 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -1003,7 +1003,7 @@ static void gpiochip_set_hierarchical_irqchip(struct gpio_chip *gc,
>                                                       &fwspec,
>                                                       false,
>                                                       NULL);
> -                       if (ret < 0) {
> +                       if (ret <= 0) {
>                                 chip_err(gc,
>                                          "can not allocate irq for GPIO line %d parent hwirq %d in hierarchy domain: %d\n",
>                                          i, parent_hwirq,
> --
> 2.30.0.rc2
>

Hi Adam,

Does this commit depend in any way on others in this series or can I
apply it directly for fixes?

Bart
Adam Lackorzynski Jan. 4, 2021, 2:43 p.m. UTC | #2
Hi,

On Mon Jan 04, 2021 at 14:57:31 +0100, Bartosz Golaszewski wrote:
> On Sat, Jan 2, 2021 at 6:59 PM Adam Lackorzynski <adam@l4re.org> wrote:
> >
> > 0 is not a proper IRQ number and also indicates failure.
> >
> > Signed-off-by: Adam Lackorzynski <adam@l4re.org>
> > ---
> >  drivers/gpio/gpiolib.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> > index b02cc2abd3b6..9667e1a62626 100644
> > --- a/drivers/gpio/gpiolib.c
> > +++ b/drivers/gpio/gpiolib.c
> > @@ -1003,7 +1003,7 @@ static void gpiochip_set_hierarchical_irqchip(struct gpio_chip *gc,
> >                                                       &fwspec,
> >                                                       false,
> >                                                       NULL);
> > -                       if (ret < 0) {
> > +                       if (ret <= 0) {
> >                                 chip_err(gc,
> >                                          "can not allocate irq for GPIO line %d parent hwirq %d in hierarchy domain: %d\n",
> >                                          i, parent_hwirq,
> > --
> > 2.30.0.rc2
> >
> 
> Does this commit depend in any way on others in this series or can I
> apply it directly for fixes?

It is independent, you can directly apply it.


Thanks, Adam
Andy Shevchenko Jan. 4, 2021, 3 p.m. UTC | #3
On Sat, Jan 2, 2021 at 8:24 PM Adam Lackorzynski <adam@l4re.org> wrote:
>
> 0 is not a proper IRQ number and also indicates failure.

Hmm... While in this case it's perhaps okay, this does not work in
general since the function can take irq_base == 0 and realloc == true.
So if we want to have a code that somebody may reuse better not to do
this (we never get 0 from this function).

In my humble opinion NAK.
diff mbox series

Patch

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index b02cc2abd3b6..9667e1a62626 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1003,7 +1003,7 @@  static void gpiochip_set_hierarchical_irqchip(struct gpio_chip *gc,
 						      &fwspec,
 						      false,
 						      NULL);
-			if (ret < 0) {
+			if (ret <= 0) {
 				chip_err(gc,
 					 "can not allocate irq for GPIO line %d parent hwirq %d in hierarchy domain: %d\n",
 					 i, parent_hwirq,