From: Martin Kaiser <lists@kaiser.cx>
To: Haotian Zhang <vulab@iscas.ac.cn>
Cc: ansuelsmth@gmail.com, olivia@selenic.com,
herbert@gondor.apana.org.au, linux-crypto@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hwrng: airoha: Fix wait_for_completion_timeout return value check
Date: Mon, 8 Dec 2025 09:40:28 +0100 [thread overview]
Message-ID: <aTaO_EWbszgGeqz-@akranes.kaiser.cx> (raw)
In-Reply-To: <20251208080836.1010-1-vulab@iscas.ac.cn>
Thus wrote Haotian Zhang (vulab@iscas.ac.cn):
> wait_for_completion_timeout() returns an unsigned long
> representing remaining jiffies, not an int. It returns
> 0 on timeout and a positive value on completion, never
> a negative error code.
> Change the type of ret to unsigned long, and update the
> check to == 0 to correctly detect timeouts.
> Fixes: e53ca8efcc5e ("hwrng: airoha - add support for Airoha EN7581 TRNG")
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> ---
> drivers/char/hw_random/airoha-trng.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> diff --git a/drivers/char/hw_random/airoha-trng.c b/drivers/char/hw_random/airoha-trng.c
> index 1dbfa9505c21..3e94233e1389 100644
> --- a/drivers/char/hw_random/airoha-trng.c
> +++ b/drivers/char/hw_random/airoha-trng.c
> @@ -76,7 +76,7 @@ static int airoha_trng_irq_unmask(struct airoha_trng *trng)
> static int airoha_trng_init(struct hwrng *rng)
> {
> struct airoha_trng *trng = container_of(rng, struct airoha_trng, rng);
> - int ret;
> + unsigned long ret;
> u32 val;
> val = readl(trng->base + TRNG_NS_SEK_AND_DAT_EN);
> @@ -88,7 +88,7 @@ static int airoha_trng_init(struct hwrng *rng)
> writel(0, trng->base + TRNG_HEALTH_TEST_SW_RST);
> ret = wait_for_completion_timeout(&trng->rng_op_done, BUSY_LOOP_TIMEOUT);
> - if (ret <= 0) {
> + if (ret == 0) {
> dev_err(trng->dev, "Timeout waiting for Health Check\n");
> airoha_trng_irq_mask(trng);
> return -ENODEV;
> --
> 2.50.1.windows.1
Reviewed-by: Martin Kaiser <martin@kaiser.cx>
next prev parent reply other threads:[~2025-12-08 9:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-08 8:08 [PATCH] hwrng: airoha: Fix wait_for_completion_timeout return value check Haotian Zhang
2025-12-08 8:40 ` Martin Kaiser [this message]
2025-12-12 5:22 ` kernel test robot
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=aTaO_EWbszgGeqz-@akranes.kaiser.cx \
--to=lists@kaiser.cx \
--cc=ansuelsmth@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olivia@selenic.com \
--cc=vulab@iscas.ac.cn \
/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