Re: [PATCH v4 1/2] hwrng: imx-rngc: Use optional clock

From: Martin Kaiser

Date: Wed Nov 26 2025 - 15:31:00 EST


Thus wrote Jean-Michel Hautbois via B4 Relay (devnull+jeanmichel.hautbois.yoseli.org@xxxxxxxxxx):

> From: Jean-Michel Hautbois <jeanmichel.hautbois@xxxxxxxxxx>

> Change devm_clk_get() to devm_clk_get_optional() to support platforms
> where the RNG clock is always enabled and not exposed via the clock
> framework (such as ColdFire MCF54418).

> Reviewed-by: Frank Li <Frank.Li@xxxxxxx>
> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@xxxxxxxxxx>
> ---
> drivers/char/hw_random/imx-rngc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

> diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c
> index 241664a9b5d9..d6a847e48339 100644
> --- a/drivers/char/hw_random/imx-rngc.c
> +++ b/drivers/char/hw_random/imx-rngc.c
> @@ -259,7 +259,7 @@ static int __init imx_rngc_probe(struct platform_device *pdev)
> if (IS_ERR(rngc->base))
> return PTR_ERR(rngc->base);

> - rngc->clk = devm_clk_get(&pdev->dev, NULL);
> + rngc->clk = devm_clk_get_optional(&pdev->dev, NULL);
> if (IS_ERR(rngc->clk))
> return dev_err_probe(&pdev->dev, PTR_ERR(rngc->clk), "Cannot get rng_clk\n");

The clock is not optional on a standard imx25 system. If it's missing in the
device tree, the rngb will not work and we should not load the driver.

Should we call devm_clk_get or devm_clk_get_optional, depending on the
detected device?

Best regards,
Martin