Skip to contentSkip to conversation

NFC: pn544: i2c: fix error handling of irq_of_parse_and_map

PATCH New Dmitry Torokhov 1 participant 1 message Nov 14, 2014 NFC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFC: pn544: i2c: fix error handling of irq_of_parse_and_map

Return value of irq_of_parse_and_map() is unsigned int, with 0 indicating failure, so testing for negative result never works.

---

Not tested, found by casual code inspection.

 drivers/nfc/pn544/i2c.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/nfc/pn544/i2c.c +4 -5
index 440291a..cfb3f0b 100644
@@ -918,13 +918,12 @@ static int pn544_hci_i2c_of_request_resources(struct i2c_client *client)
 	}
 
 	/* IRQ */
-	ret = irq_of_parse_and_map(pp, 0);
-	if (ret < 0) {
-		nfc_err(&client->dev,
-			"Unable to get irq, error: %d\n", ret);
+	client->irq = irq_of_parse_and_map(pp, 0);
+	if (!client->irq) {
+		nfc_err(&client->dev, "Unable to get irq\n");
+		ret = -EINVAL;
 		goto err_gpio_fw;
 	}
-	client->irq = ret;
 
 	return 0;
 
Signature · 5 lines
2.1.0.rc2.206.gedb03e5


-- 
Dmitry