* [PATCH] NFC: st21nfcb: fix error handling of irq_of_parse_and_map
@ 2014-11-14 22:35 Dmitry Torokhov
2014-11-15 20:51 ` Christophe RICARD
0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Torokhov @ 2014-11-14 22:35 UTC (permalink / raw)
To: Lauro Ramos Venancio
Cc: Aloisio Almeida Jr, Samuel Ortiz, Christophe Ricard,
linux-wireless, linux-kernel
Return value of irq_of_parse_and_map() is unsigned int, with 0
indicating failure, so testing for negative result never works.
Also report error returned by devm_gpio_request_one instead of
clobbering it with -ENODEV.
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
---
Not tested, found by casual code inspection.
drivers/nfc/st21nfcb/i2c.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/nfc/st21nfcb/i2c.c b/drivers/nfc/st21nfcb/i2c.c
index c5d2427..abe73ec 100644
--- a/drivers/nfc/st21nfcb/i2c.c
+++ b/drivers/nfc/st21nfcb/i2c.c
@@ -258,19 +258,18 @@ static int st21nfcb_nci_i2c_of_request_resources(struct i2c_client *client)
GPIOF_OUT_INIT_HIGH, "clf_reset");
if (r) {
nfc_err(&client->dev, "Failed to request reset pin\n");
- return -ENODEV;
+ return r;
}
phy->gpio_reset = gpio;
/* IRQ */
- r = irq_of_parse_and_map(pp, 0);
- if (r < 0) {
- nfc_err(&client->dev, "Unable to get irq, error: %d\n", r);
- return r;
+ client->irq = irq_of_parse_and_map(pp, 0);
+ if (!client->irq) {
+ nfc_err(&client->dev, "Unable to get irq\n");
+ return -EINVAL;
}
phy->irq_polarity = irq_get_trigger_type(r);
- client->irq = r;
return 0;
}
--
2.1.0.rc2.206.gedb03e5
--
Dmitry
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] NFC: st21nfcb: fix error handling of irq_of_parse_and_map
2014-11-14 22:35 [PATCH] NFC: st21nfcb: fix error handling of irq_of_parse_and_map Dmitry Torokhov
@ 2014-11-15 20:51 ` Christophe RICARD
0 siblings, 0 replies; 2+ messages in thread
From: Christophe RICARD @ 2014-11-15 20:51 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Lauro Ramos Venancio, Aloisio Almeida Jr, Samuel Ortiz,
linux-wireless, linux-kernel, linux-nfc
Hi Dmitry,
Thank you for your feedback.
A patch got already pushed earlier this month:
https://lists.01.org/pipermail/linux-nfc/2014-November/003126.html
The i2c-core is already running the i2c_of_parse_and_map function when
registering the slave device when using dts. This step got removed for
this reason.
However, i will take into account your second point in order to report
devm_gpio_request_one instead of -ENODEV in a future patchset.
Best Regards
Christophe
On Fri, 14 Nov 2014 14:35:27 -0800
Dmitry Torokhov <dtor@chromium.org> wrote:
> Return value of irq_of_parse_and_map() is unsigned int, with 0
> indicating failure, so testing for negative result never works.
>
> Also report error returned by devm_gpio_request_one instead of
> clobbering it with -ENODEV.
>
> Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
> ---
>
> Not tested, found by casual code inspection.
>
> drivers/nfc/st21nfcb/i2c.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/nfc/st21nfcb/i2c.c b/drivers/nfc/st21nfcb/i2c.c
> index c5d2427..abe73ec 100644
> --- a/drivers/nfc/st21nfcb/i2c.c
> +++ b/drivers/nfc/st21nfcb/i2c.c
> @@ -258,19 +258,18 @@ static int
> st21nfcb_nci_i2c_of_request_resources(struct i2c_client *client)
> GPIOF_OUT_INIT_HIGH, "clf_reset"); if (r) {
> nfc_err(&client->dev, "Failed to request reset
> pin\n");
> - return -ENODEV;
> + return r;
> }
> phy->gpio_reset = gpio;
>
> /* IRQ */
> - r = irq_of_parse_and_map(pp, 0);
> - if (r < 0) {
> - nfc_err(&client->dev, "Unable to get irq, error:
> %d\n", r);
> - return r;
> + client->irq = irq_of_parse_and_map(pp, 0);
> + if (!client->irq) {
> + nfc_err(&client->dev, "Unable to get irq\n");
> + return -EINVAL;
> }
>
> phy->irq_polarity = irq_get_trigger_type(r);
> - client->irq = r;
>
> return 0;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-15 20:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-14 22:35 [PATCH] NFC: st21nfcb: fix error handling of irq_of_parse_and_map Dmitry Torokhov
2014-11-15 20:51 ` Christophe RICARD
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).