]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
hwrng: imx-rngc - fix the timeout for init and self check
authorMartin Kaiser <martin@kaiser.cx>
Thu, 15 Jun 2023 14:49:59 +0000 (15:49 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Aug 2023 09:33:45 +0000 (11:33 +0200)
commit d744ae7477190967a3ddc289e2cd4ae59e8b1237 upstream.

Fix the timeout that is used for the initialisation and for the self
test. wait_for_completion_timeout expects a timeout in jiffies, but
RNGC_TIMEOUT is in milliseconds. Call msecs_to_jiffies to do the
conversion.

Cc: stable@vger.kernel.org
Fixes: 1d5449445bd0 ("hwrng: mx-rngc - add a driver for Freescale RNGC")
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/hw_random/imx-rngc.c

index 48194d1a607673c7605cbcf4e1d6f26f707a231e..5a31887867d6d9b4e1fcd16521007ed52bb42b80 100644 (file)
@@ -104,7 +104,7 @@ static int imx_rngc_self_test(struct imx_rngc *rngc)
        cmd = readl(rngc->base + RNGC_COMMAND);
        writel(cmd | RNGC_CMD_SELF_TEST, rngc->base + RNGC_COMMAND);
 
-       ret = wait_for_completion_timeout(&rngc->rng_op_done, RNGC_TIMEOUT);
+       ret = wait_for_completion_timeout(&rngc->rng_op_done, msecs_to_jiffies(RNGC_TIMEOUT));
        if (!ret) {
                imx_rngc_irq_mask_clear(rngc);
                return -ETIMEDOUT;
@@ -187,9 +187,7 @@ static int imx_rngc_init(struct hwrng *rng)
                cmd = readl(rngc->base + RNGC_COMMAND);
                writel(cmd | RNGC_CMD_SEED, rngc->base + RNGC_COMMAND);
 
-               ret = wait_for_completion_timeout(&rngc->rng_op_done,
-                               RNGC_TIMEOUT);
-
+               ret = wait_for_completion_timeout(&rngc->rng_op_done, msecs_to_jiffies(RNGC_TIMEOUT));
                if (!ret) {
                        imx_rngc_irq_mask_clear(rngc);
                        return -ETIMEDOUT;