Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH] hwrng: imx-rngc: check clk_prepare_enable() return value
@ 2026-08-28  2:54 Li Youhong
  2026-08-28 19:44 ` Frank Li
  2026-09-01 13:37 ` Martin Kaiser
  0 siblings, 2 replies; 3+ messages in thread
From: Li Youhong @ 2026-08-28  2:54 UTC (permalink / raw)
  To: olivia, herbert; +Cc: linux-crypto, imx, Li Youhong

From: Li Youhong <liyouhong@kylinos.cn>

The driver ignored clk_prepare_enable() failures during probe and
resume.  If enabling the RNG clock fails, subsequent register accesses
or resume after system sleep may not work while the driver still reports
success.

Signed-off-by: Li Youhong <liyouhong@kylinos.cn>
---
 drivers/char/hw_random/imx-rngc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c
index 7693328f1056..0545a1870146 100644
--- a/drivers/char/hw_random/imx-rngc.c
+++ b/drivers/char/hw_random/imx-rngc.c
@@ -266,7 +266,9 @@ static int __init imx_rngc_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	clk_prepare_enable(rngc->clk);
+	ret = clk_prepare_enable(rngc->clk);
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "Cannot enable rng_clk\n");
 
 	ver_id = readl(rngc->base + RNGC_VER_ID);
 	rng_type = FIELD_GET(RNG_TYPE, ver_id);
@@ -338,9 +340,7 @@ static int imx_rngc_resume(struct device *dev)
 {
 	struct imx_rngc *rngc = dev_get_drvdata(dev);
 
-	clk_prepare_enable(rngc->clk);
-
-	return 0;
+	return clk_prepare_enable(rngc->clk);
 }
 
 static const struct dev_pm_ops imx_rngc_pm_ops = {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] hwrng: imx-rngc: check clk_prepare_enable() return value
  2026-08-28  2:54 [PATCH] hwrng: imx-rngc: check clk_prepare_enable() return value Li Youhong
@ 2026-08-28 19:44 ` Frank Li
  2026-09-01 13:37 ` Martin Kaiser
  1 sibling, 0 replies; 3+ messages in thread
From: Frank Li @ 2026-08-28 19:44 UTC (permalink / raw)
  To: Li Youhong; +Cc: olivia, herbert, linux-crypto, imx, Li Youhong

On Fri, Aug 28, 2026 at 10:54:23AM +0800, Li Youhong wrote:
>
> From: Li Youhong <liyouhong@kylinos.cn>
>
> The driver ignored clk_prepare_enable() failures during probe and
> resume.  If enabling the RNG clock fails, subsequent register accesses
> or resume after system sleep may not work while the driver still reports
> success.
>
> Signed-off-by: Li Youhong <liyouhong@kylinos.cn>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  drivers/char/hw_random/imx-rngc.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c
> index 7693328f1056..0545a1870146 100644
> --- a/drivers/char/hw_random/imx-rngc.c
> +++ b/drivers/char/hw_random/imx-rngc.c
> @@ -266,7 +266,9 @@ static int __init imx_rngc_probe(struct platform_device *pdev)
>         if (irq < 0)
>                 return irq;
>
> -       clk_prepare_enable(rngc->clk);
> +       ret = clk_prepare_enable(rngc->clk);
> +       if (ret)
> +               return dev_err_probe(&pdev->dev, ret, "Cannot enable rng_clk\n");
>
>         ver_id = readl(rngc->base + RNGC_VER_ID);
>         rng_type = FIELD_GET(RNG_TYPE, ver_id);
> @@ -338,9 +340,7 @@ static int imx_rngc_resume(struct device *dev)
>  {
>         struct imx_rngc *rngc = dev_get_drvdata(dev);
>
> -       clk_prepare_enable(rngc->clk);
> -
> -       return 0;
> +       return clk_prepare_enable(rngc->clk);
>  }
>
>  static const struct dev_pm_ops imx_rngc_pm_ops = {
> --
> 2.25.1
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] hwrng: imx-rngc: check clk_prepare_enable() return value
  2026-08-28  2:54 [PATCH] hwrng: imx-rngc: check clk_prepare_enable() return value Li Youhong
  2026-08-28 19:44 ` Frank Li
@ 2026-09-01 13:37 ` Martin Kaiser
  1 sibling, 0 replies; 3+ messages in thread
From: Martin Kaiser @ 2026-09-01 13:37 UTC (permalink / raw)
  To: Li Youhong; +Cc: olivia, herbert, linux-crypto, imx, Li Youhong

Thus wrote Li Youhong (dayou5941@163.com):

> From: Li Youhong <liyouhong@kylinos.cn>

> The driver ignored clk_prepare_enable() failures during probe and
> resume.  If enabling the RNG clock fails, subsequent register accesses
> or resume after system sleep may not work while the driver still reports
> success.

> Signed-off-by: Li Youhong <liyouhong@kylinos.cn>
> ---
>  drivers/char/hw_random/imx-rngc.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

> diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c
> index 7693328f1056..0545a1870146 100644
> --- a/drivers/char/hw_random/imx-rngc.c
> +++ b/drivers/char/hw_random/imx-rngc.c
> @@ -266,7 +266,9 @@ static int __init imx_rngc_probe(struct platform_device *pdev)
>  	if (irq < 0)
>  		return irq;

> -	clk_prepare_enable(rngc->clk);
> +	ret = clk_prepare_enable(rngc->clk);
> +	if (ret)
> +		return dev_err_probe(&pdev->dev, ret, "Cannot enable rng_clk\n");

>  	ver_id = readl(rngc->base + RNGC_VER_ID);
>  	rng_type = FIELD_GET(RNG_TYPE, ver_id);
> @@ -338,9 +340,7 @@ static int imx_rngc_resume(struct device *dev)
>  {
>  	struct imx_rngc *rngc = dev_get_drvdata(dev);

> -	clk_prepare_enable(rngc->clk);
> -
> -	return 0;
> +	return clk_prepare_enable(rngc->clk);
>  }

>  static const struct dev_pm_ops imx_rngc_pm_ops = {
> -- 
> 2.25.1

Reviewed-by: Martin Kaiser <martin@kaiser.cx>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-01 14:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-28  2:54 [PATCH] hwrng: imx-rngc: check clk_prepare_enable() return value Li Youhong
2026-08-28 19:44 ` Frank Li
2026-09-01 13:37 ` Martin Kaiser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox