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

Martin Kaiser martin at kaiser.cx
Thu Nov 27 05:22:34 PST 2025


Hi Geert,

Thus wrote Geert Uytterhoeven (geert at linux-m68k.org):

> 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.

ok, understood. With this clarification, I'm happy with the patch.

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

Thanks,
Martin



More information about the linux-arm-kernel mailing list