Re: [PATCH v4 5/7] clk: Use the generic OF phandle parsing in only one place
From: Frank Li
Date: Fri Jul 24 2026 - 14:42:23 EST
On Fri, Jul 17, 2026 at 05:59:21PM +0200, Miquel Raynal (Schneider Electric) wrote:
> There should be one single entry in the OF world, so that the way we
> parse the DT is always the same. make sure this is the case by avoid
> calling of_parse_phandle_with_args() from of_clk_get_parent_name(). This
> is even more relevant as we currently fail to parse clock-ranges. As a
> result, it seems to be safer to directly call of_parse_clkspec() there,
> but doing so implies that we do not try the "clock-ranges" path if we
> already found a "clocks" property..
Sorry, I can't understand well what commit said.
Replaces the use of of_parse_phandle_with_args() with
of_parse_clkspec() inside of_clk_get_parent_name(). It also modifies
of_parse_clkspec() to stop traversing up the device tree if a "clocks"
property is found.
Is AI's words what you means?
Frank
>
> Suggested-by: Stephen Boyd <sboyd@xxxxxxxxxx>
> Fixes: 4472287a3b2f5 ("clk: Introduce of_clk_get_hw_from_clkspec()")
> Signed-off-by: Miquel Raynal (Schneider Electric) <miquel.raynal@xxxxxxxxxxx>
> Reviewed-by: Brian Masney <bmasney@xxxxxxxxxx>
> ---
> 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 7d63d81ebc09..45f5d7a4ccc1 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -5219,6 +5219,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;
> @@ -5364,8 +5366,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;
>
>
> --
> 2.54.0
>