From: Dan Carpenter <dan.carpenter@oracle.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Xin Ji <xji@analogixsemi.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH 2/3] usb: typec: anx7411: fix error checking in anx7411_get_gpio_irq()
Date: Fri, 22 Jul 2022 09:29:07 +0300 [thread overview]
Message-ID: <YtpDs8VsWIbl/Smd@kili> (raw)
In-Reply-To: <YtpC5s4/AD8vFz+X@kili>
This is a minor bug which means that certain error messages are not
printed.
The devm_gpiod_get_optional() function can return either error pointers
or NULL. It returns error pointers if there is an allocation failure,
or a similar issue. It returns NULL if no GPIO was assigned to the
requested function. Print an error in either case.
The gpiod_to_irq() function never returns zero. It either returns
a positive IRQ number or a negative error code.
Fixes: fe6d8a9c8e64 ("usb: typec: anx7411: Add Analogix PD ANX7411 support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/usb/typec/anx7411.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/typec/anx7411.c b/drivers/usb/typec/anx7411.c
index 4f7a5cc968d0..311b56aaea9f 100644
--- a/drivers/usb/typec/anx7411.c
+++ b/drivers/usb/typec/anx7411.c
@@ -1326,13 +1326,13 @@ static void anx7411_get_gpio_irq(struct anx7411_data *ctx)
struct device *dev = &ctx->tcpc_client->dev;
ctx->intp_gpiod = devm_gpiod_get_optional(dev, "interrupt", GPIOD_IN);
- if (!ctx->intp_gpiod) {
+ if (IS_ERR_OR_NULL(ctx->intp_gpiod)) {
dev_err(dev, "no interrupt gpio property\n");
return;
}
ctx->intp_irq = gpiod_to_irq(ctx->intp_gpiod);
- if (!ctx->intp_irq)
+ if (ctx->intp_irq < 0)
dev_err(dev, "failed to get GPIO IRQ\n");
}
--
2.35.1
next prev parent reply other threads:[~2022-07-22 6:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-22 6:25 [PATCH 1/3] usb: typec: anx7411: Fix an array out of bounds Dan Carpenter
2022-07-22 6:29 ` Dan Carpenter [this message]
2022-07-22 7:16 ` [PATCH 2/3] usb: typec: anx7411: fix error checking in anx7411_get_gpio_irq() Xin Ji
2022-07-22 6:29 ` [PATCH 3/3] usb: typec: anx7411: use semi-colons instead of commas Dan Carpenter
2022-07-22 7:17 ` Xin Ji
2022-07-22 7:15 ` [PATCH 1/3] usb: typec: anx7411: Fix an array out of bounds Xin Ji
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YtpDs8VsWIbl/Smd@kili \
--to=dan.carpenter@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=xji@analogixsemi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox