From 57d728b4ab15a8af890013bb0f302e7733f7c1c6 Mon Sep 17 00:00:00 2001 From: "Miquel Raynal (Schneider Electric)" Date: Fri, 7 Aug 2026 17:24:06 +0200 Subject: [PATCH] clk: Use the generic OF phandle parsing in only one place Ideally, there should be one single entry in the OF world. This way, the DT parsing logic is always identical. At this stage, we call of_parse_phandle_with_args() in: - of_parse_clkspec() - of_clk_get_parent_name() which kinds of defeats the above statement. Furthermore, when this call is done from of_clk_get_parent_name(), we fail to parse the 'clock-ranges' property. Make sure DT world is entered only once by calling of_parse_clkspec() from of_clk_get_parent_name(). Doing so implies that we do not try the "clock-ranges" path if we already found a "clocks" property. Suggested-by: Stephen Boyd Fixes: 4472287a3b2f5 ("clk: Introduce of_clk_get_hw_from_clkspec()") Signed-off-by: Miquel Raynal (Schneider Electric) Reviewed-by: Brian Masney Reviewed-by: Frank Li Signed-off-by: Brian Masney --- drivers/clk/clk.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 632213a38665..cde94166835e 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -5321,6 +5321,8 @@ static int of_parse_clkspec(const struct device_node *np, int index, * has a "clock-ranges" property, then we can try one of its * clocks. */ + if (of_property_present(np, "clocks")) + break; np = np->parent; if (np && !of_property_present(np, "clock-ranges")) break; @@ -5466,8 +5468,7 @@ const char *of_clk_get_parent_name(const struct device_node *np, int index) int count; struct clk *clk; - rc = of_parse_phandle_with_args(np, "clocks", "#clock-cells", index, - &clkspec); + rc = of_parse_clkspec(np, index, NULL, &clkspec); if (rc) return NULL;