Re: [PATCH 03/42] clk: at91: sam9x60: switch to parent_hw and parent_data

From: Stephen Boyd
Date: Fri Jul 28 2023 - 23:28:48 EST


Quoting Claudiu Beznea (2023-07-26 22:31:17)
> @@ -177,31 +178,34 @@ static const struct {
>
> static void __init sam9x60_pmc_setup(struct device_node *np)
> {
> + struct clk_hw *td_slck_hw, *md_slck_hw, *main_xtal_hw, *main_rc_hw, *main_osc_hw;
> + struct clk_hw *parent_hws[6], *hw, *usbck_hw;
> + static struct clk_parent_data parent_data;
> struct clk_range range = CLK_RANGE(0, 0);
> - const char *td_slck_name, *md_slck_name, *mainxtal_name;
> + const char *main_xtal_name = "main_xtal";
> struct pmc_data *sam9x60_pmc;
> - const char *parent_names[6];
> - struct clk_hw *main_osc_hw;
> struct regmap *regmap;
> - struct clk_hw *hw;
> + struct clk *clk;
> int i;
>
> - i = of_property_match_string(np, "clock-names", "td_slck");
> - if (i < 0)
> + clk = of_clk_get_by_name(np, "td_slck");
> + if (IS_ERR(clk))
> return;
> -
> - td_slck_name = of_clk_get_parent_name(np, i);
> -
> - i = of_property_match_string(np, "clock-names", "md_slck");
> - if (i < 0)
> + td_slck_hw = __clk_get_hw(clk);

Don't introduce more usage of __clk_get_hw(). The index for "td_slck"
should be known, and it can be used as the index member in struct
clk_parent_data. This allows the clk framework to lazily find the
parent, instead of requiring the parent to be registered before this
code runs. It also reduces the usage of __clk_get_hw().