2014-11-14 21:33:02

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH] gpio-tz1090: fix error handling of irq_of_parse_and_map

irq_of_parse_and_map() returns 0 on error, so testing for negative
result never works.

Signed-off-by: Dmitry Torokhov <[email protected]>
---

Not tested, found by casual inspection of the code.

drivers/gpio/gpio-tz1090.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-tz1090.c b/drivers/gpio/gpio-tz1090.c
index 9e90177..e3024bb 100644
--- a/drivers/gpio/gpio-tz1090.c
+++ b/drivers/gpio/gpio-tz1090.c
@@ -446,7 +446,7 @@ static int tz1090_gpio_bank_probe(struct tz1090_gpio_bank_info *info)
bank->irq = irq_of_parse_and_map(np, 0);

/* The interrupt is optional (it may be used by another core on chip) */
- if (bank->irq < 0) {
+ if (!bank->irq) {
dev_info(dev, "IRQ not provided for bank %u, IRQs disabled\n",
info->index);
return 0;
--
2.1.0.rc2.206.gedb03e5


--
Dmitry


2014-11-14 23:53:12

by James Hogan

[permalink] [raw]
Subject: Re: [PATCH] gpio-tz1090: fix error handling of irq_of_parse_and_map

On Fri, Nov 14, 2014 at 01:32:56PM -0800, Dmitry Torokhov wrote:
> irq_of_parse_and_map() returns 0 on error, so testing for negative
> result never works.
>
> Signed-off-by: Dmitry Torokhov <[email protected]>

Good catch, thanks!

Acked-by: James Hogan <[email protected]>

A quick coccinelle script shows up numerous other cases of this error
around the kernel tree too...

Cheers
James

> ---
>
> Not tested, found by casual inspection of the code.
>
> drivers/gpio/gpio-tz1090.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-tz1090.c b/drivers/gpio/gpio-tz1090.c
> index 9e90177..e3024bb 100644
> --- a/drivers/gpio/gpio-tz1090.c
> +++ b/drivers/gpio/gpio-tz1090.c
> @@ -446,7 +446,7 @@ static int tz1090_gpio_bank_probe(struct tz1090_gpio_bank_info *info)
> bank->irq = irq_of_parse_and_map(np, 0);
>
> /* The interrupt is optional (it may be used by another core on chip) */
> - if (bank->irq < 0) {
> + if (!bank->irq) {
> dev_info(dev, "IRQ not provided for bank %u, IRQs disabled\n",
> info->index);
> return 0;
> --
> 2.1.0.rc2.206.gedb03e5
>
>
> --
> Dmitry


Attachments:
(No filename) (1.12 kB)
signature.asc (819.00 B)
Digital signature
Download all attachments

2014-11-15 00:44:10

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] gpio-tz1090: fix error handling of irq_of_parse_and_map

On Friday, November 14, 2014 11:53:07 PM James Hogan wrote:
> On Fri, Nov 14, 2014 at 01:32:56PM -0800, Dmitry Torokhov wrote:
> > irq_of_parse_and_map() returns 0 on error, so testing for negative
> > result never works.
> >
> > Signed-off-by: Dmitry Torokhov <[email protected]>
>
> Good catch, thanks!
>
> Acked-by: James Hogan <[email protected]>
>
> A quick coccinelle script shows up numerous other cases of this error
> around the kernel tree too...

Yeah, I sent out a few patches today.

Thanks,
Dmitry

2014-11-27 13:35:29

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH] gpio-tz1090: fix error handling of irq_of_parse_and_map

On Fri, Nov 14, 2014 at 10:32 PM, Dmitry Torokhov <[email protected]> wrote:

> irq_of_parse_and_map() returns 0 on error, so testing for negative
> result never works.
>
> Signed-off-by: Dmitry Torokhov <[email protected]>

Patch applied with James' ACK.

Yours,
Linus Walleij