From: Dan Carpenter <dan.carpenter@linaro.org>
To: "Marek Behún" <kabel@kernel.org>
Cc: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] platform: cznic: turris-omnia-mcu: Fix error check in omnia_mcu_register_trng()
Date: Thu, 5 Sep 2024 16:16:53 +0300 [thread overview]
Message-ID: <2b10f2e1-82d1-4f33-92c4-e0cb28b9edac@stanley.mountain> (raw)
The gpiod_to_irq() function never returns zero. It returns negative
error codes or a positive IRQ number. Update the checking to check
for negatives.
Fixes: 41bb142a4028 ("platform: cznic: turris-omnia-mcu: Add support for MCU provided TRNG")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
For more information about the history of IRQ return values see my blog:
https://staticthinking.wordpress.com/2023/08/07/writing-a-check-for-zero-irq-error-codes/
The gpiod_to_irq() function was modified to not return zero in 2016.
drivers/platform/cznic/turris-omnia-mcu-trng.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/cznic/turris-omnia-mcu-trng.c b/drivers/platform/cznic/turris-omnia-mcu-trng.c
index ad953fb3c37a..9a1d9292dc9a 100644
--- a/drivers/platform/cznic/turris-omnia-mcu-trng.c
+++ b/drivers/platform/cznic/turris-omnia-mcu-trng.c
@@ -70,8 +70,8 @@ int omnia_mcu_register_trng(struct omnia_mcu *mcu)
irq_idx = omnia_int_to_gpio_idx[__bf_shf(OMNIA_INT_TRNG)];
irq = gpiod_to_irq(gpio_device_get_desc(mcu->gc.gpiodev, irq_idx));
- if (!irq)
- return dev_err_probe(dev, -ENXIO, "Cannot get TRNG IRQ\n");
+ if (irq < 0)
+ return dev_err_probe(dev, irq, "Cannot get TRNG IRQ\n");
/*
* If someone else cleared the TRNG interrupt but did not read the
--
2.45.2
next reply other threads:[~2024-09-05 13:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-05 13:16 Dan Carpenter [this message]
2024-09-05 16:07 ` Marek Behún
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=2b10f2e1-82d1-4f33-92c4-e0cb28b9edac@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=arnd@arndb.de \
--cc=bartosz.golaszewski@linaro.org \
--cc=kabel@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®