Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwrng: imx-rngc: propagate clock enable errors
@ 2026-08-30 13:12 Pengpeng Hou
  2026-08-31 15:49 ` Frank Li
  2026-09-01 13:40 ` Martin Kaiser
  0 siblings, 2 replies; 3+ messages in thread
From: Pengpeng Hou @ 2026-08-30 13:12 UTC (permalink / raw)
  To: Olivia Mackall
  Cc: Pengpeng Hou, Herbert Xu, Frank Li, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, linux-crypto, imx,
	linux-arm-kernel, linux-kernel

imx_rngc_probe() reads hardware registers after enabling its clock without
checking the result, and the runtime resume callback always reports success
after the same unchecked operation.

Propagate clock-enable errors before accessing the RNG and to the
runtime-PM
core on resume.

Fixes: 1d5449445bd0 ("hwrng: mx-rngc - add a driver for Freescale RNGC")
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.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 7693328f10564..00a21d62c79c3 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 ret;
 
 	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 = {

base-commit: 08dbfad3f5040f5bdb6c529da20d6d4e81fefd72
-- 
2.50.1



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

* Re: [PATCH] hwrng: imx-rngc: propagate clock enable errors
  2026-08-30 13:12 [PATCH] hwrng: imx-rngc: propagate clock enable errors Pengpeng Hou
@ 2026-08-31 15:49 ` Frank Li
  2026-09-01 13:40 ` Martin Kaiser
  1 sibling, 0 replies; 3+ messages in thread
From: Frank Li @ 2026-08-31 15:49 UTC (permalink / raw)
  To: Pengpeng Hou
  Cc: Olivia Mackall, Herbert Xu, Frank Li, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, linux-crypto, imx,
	linux-arm-kernel, linux-kernel

On Sun, Aug 30, 2026 at 09:12:53PM +0800, Pengpeng Hou wrote:
> imx_rngc_probe() reads hardware registers after enabling its clock without
> checking the result, and the runtime resume callback always reports success
> after the same unchecked operation.
>
> Propagate clock-enable errors before accessing the RNG and to the
> runtime-PM
> core on resume.

Nit: wrap to first line

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

>
> Fixes: 1d5449445bd0 ("hwrng: mx-rngc - add a driver for Freescale RNGC")
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.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 7693328f10564..00a21d62c79c3 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 ret;
>
>  	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 = {
>
> base-commit: 08dbfad3f5040f5bdb6c529da20d6d4e81fefd72
> --
> 2.50.1
>
>


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

* Re: [PATCH] hwrng: imx-rngc: propagate clock enable errors
  2026-08-30 13:12 [PATCH] hwrng: imx-rngc: propagate clock enable errors Pengpeng Hou
  2026-08-31 15:49 ` Frank Li
@ 2026-09-01 13:40 ` Martin Kaiser
  1 sibling, 0 replies; 3+ messages in thread
From: Martin Kaiser @ 2026-09-01 13:40 UTC (permalink / raw)
  To: Pengpeng Hou
  Cc: Olivia Mackall, Herbert Xu, Frank Li, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, linux-crypto, imx,
	linux-arm-kernel, linux-kernel

Thus wrote Pengpeng Hou (pengpeng@iscas.ac.cn):

> imx_rngc_probe() reads hardware registers after enabling its clock without
> checking the result, and the runtime resume callback always reports success
> after the same unchecked operation.

> Propagate clock-enable errors before accessing the RNG and to the
> runtime-PM
> core on resume.

> Fixes: 1d5449445bd0 ("hwrng: mx-rngc - add a driver for Freescale RNGC")
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.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 7693328f10564..00a21d62c79c3 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 ret;

>  	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 = {

> base-commit: 08dbfad3f5040f5bdb6c529da20d6d4e81fefd72
> -- 
> 2.50.1

The same patch was sent 2 days ago.

https://lore.kernel.org/linux-crypto/apHlIGM3_GHf86fK@SMW015318/T/#t


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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-30 13:12 [PATCH] hwrng: imx-rngc: propagate clock enable errors Pengpeng Hou
2026-08-31 15:49 ` Frank Li
2026-09-01 13:40 ` Martin Kaiser

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