Skip to contentSkip to conversation

gpio-tz1090: fix error handling of irq_of_parse_and_map

PATCH In review Dmitry Torokhov 3 participants 4 messages Nov 14, 2014 – Nov 27, 2014 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---

Not tested, found by casual inspection of the code.

 drivers/gpio/gpio-tz1090.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-tz1090.c +1 -1
index 9e90177..e3024bb 100644
@@ -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;
Signature · 5 lines
2.1.0.rc2.206.gedb03e5


-- 
Dmitry
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Dmitry Torokhov

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

Good catch, thanks!

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

Cheers
James

Quoted 26 lines

---

Not tested, found by casual inspection of the code.

 drivers/gpio/gpio-tz1090.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-tz1090.c +1 -1
index 9e90177..e3024bb 100644
@@ -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;
Signature · 5 lines
2.1.0.rc2.206.gedb03e5


-- 
Dmitry
#2 lore raw
Quoted 4 lines · James Hogan
Quoted 3 lines · Dmitry Torokhov

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

Quoted 8 lines
Quoted 1 line

Good catch, thanks!

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