Subject: Re: [PATCH 08/11] clk: imx: imx31: Simplify with scoped for each OF child loop

From: Jonathan Cameron <[email-masked]>
Date: Tue, 6 Jan 2026 10:23:44 +0000

On Mon, 05 Jan 2026 14:33:46 +0100
Krzysztof Kozlowski <[email-masked]> wrote:

> Use scoped for-each loop when iterating over device nodes to make code a
> bit simpler.
> 
> Signed-off-by: Krzysztof Kozlowski <[email-masked]>
Reviewed-by: Jonathan Cameron <[email-masked]>

I guess this is papering over similar compatibility issues with old DT
as the previous one (so fsl,imx-osc26m which may or may not have fallback
compatible to fixed-clock).

Jonathan

> 
> ---
> 
> Depends on first patch.
> ---
>  drivers/clk/imx/clk-imx31.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/clk/imx/clk-imx31.c b/drivers/clk/imx/clk-imx31.c
> index 4c8d9ff0b2ad..962eccac63ce 100644
> --- a/drivers/clk/imx/clk-imx31.c
> +++ b/drivers/clk/imx/clk-imx31.c
> @@ -123,18 +123,15 @@ static void __init _mx31_clocks_init(void __iomem *base, unsigned long fref)
>  
>  static void __init mx31_clocks_init_dt(struct device_node *np)
>  {
> -	struct device_node *osc_np;
>  	u32 fref = 26000000; /* default */
>  	void __iomem *ccm;
>  
> -	for_each_compatible_node(osc_np, NULL, "fixed-clock") {
> +	for_each_compatible_node_scoped(osc_np, NULL, "fixed-clock") {
>  		if (!of_device_is_compatible(osc_np, "fsl,imx-osc26m"))
>  			continue;
>  
> -		if (!of_property_read_u32(osc_np, "clock-frequency", &fref)) {
> -			of_node_put(osc_np);
> +		if (!of_property_read_u32(osc_np, "clock-frequency", &fref))
>  			break;
> -		}
>  	}
>  
>  	ccm = of_iomap(np, 0);
>