[PATCH v4 1/2] hwrng: imx-rngc: Use optional clock
Geert Uytterhoeven
geert at linux-m68k.org
Thu Nov 27 00:37:05 PST 2025
Hi Martin,
On Wed, 26 Nov 2025 at 21:30, Martin Kaiser <martin at kaiser.cx> wrote:
> Thus wrote Jean-Michel Hautbois via B4 Relay (devnull+jeanmichel.hautbois.yoseli.org at kernel.org):
>
> > From: Jean-Michel Hautbois <jeanmichel.hautbois at yoseli.org>
>
> > 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 at nxp.com>
> > Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois at yoseli.org>
> > ---
> > 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.
As the clocks property is marked required in
Documentation/devicetree/bindings/rng/imx-rng.yaml, "make dtbs_check"
should flag a missing clock.
> Should we call devm_clk_get or devm_clk_get_optional, depending on the
> detected device?
That can quickly lead to complex code. Nowadays it is fine to rely on
"make dtbs_check" for some part of the validation.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
More information about the linux-arm-kernel
mailing list