Hi, Ryan,
On 7/10/25 23:06, Ryan.Wanner@microchip.com wrote:
> From: Claudiu Beznea <claudiu.beznea@tuxon.dev>
>
> Use struct clk_parent_data instead of parent_hw for peripheral clocks.
I would prefer a description as provided for other conversions:
Use struct clk_parent_data instead of struct parent_hw as this leads
to less usage of __clk_get_hw() in SoC specific clock drivers and simpler
conversion of existing SoC specific clock drivers from parent_names to
modern clk_parent_data structures.
>
> Signed-off-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>
> [ryan.wanner@microchip.com: Add SAMA7D65 and SAM9X7 SoCs to the use the
> structs.]
> Signed-off-by: Ryan Wanner <Ryan.Wanner@microchip.com>
> ---
> drivers/clk/at91/clk-peripheral.c | 16 ++++++++--------
> drivers/clk/at91/pmc.h | 4 ++--
> drivers/clk/at91/sam9x7.c | 2 +-
> drivers/clk/at91/sama7d65.c | 2 +-
> drivers/clk/at91/sama7g5.c | 2 +-
> 5 files changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/clk/at91/clk-peripheral.c b/drivers/clk/at91/clk-peripheral.c
> index c173a44c800a..ed97b3c0a66b 100644
> --- a/drivers/clk/at91/clk-peripheral.c
> +++ b/drivers/clk/at91/clk-peripheral.c
> @@ -97,7 +97,7 @@ static const struct clk_ops peripheral_ops = {
>
> struct clk_hw * __init
> at91_clk_register_peripheral(struct regmap *regmap, const char *name,
> - const char *parent_name, struct clk_hw *parent_hw,
> + const char *parent_name, struct clk_parent_data *parent_data,
> u32 id)
> {
> struct clk_peripheral *periph;
> @@ -105,7 +105,7 @@ at91_clk_register_peripheral(struct regmap *regmap, const char *name,
> struct clk_hw *hw;
> int ret;
>
> - if (!name || !(parent_name || parent_hw) || id > PERIPHERAL_ID_MAX)
> + if (!name || !(parent_name || parent_data) || id > PERIPHERAL_ID_MAX)
> return ERR_PTR(-EINVAL);
>
> periph = kzalloc(sizeof(*periph), GFP_KERNEL);
> @@ -114,8 +114,8 @@ at91_clk_register_peripheral(struct regmap *regmap, const char *name,
>
> init.name = name;
> init.ops = &peripheral_ops;
> - if (parent_hw)
> - init.parent_hws = (const struct clk_hw **)&parent_hw;
> + if (parent_data)
> + init.parent_data = (const struct clk_parent_data *)parent_data;
> else
> init.parent_names = &parent_name;
> init.num_parents = 1;
> @@ -448,7 +448,7 @@ struct clk_hw * __init
> at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock,
> const struct clk_pcr_layout *layout,
> const char *name, const char *parent_name,
> - struct clk_hw *parent_hw,
> + struct clk_parent_data *parent_data,
> u32 id, const struct clk_range *range,
> int chg_pid, unsigned long flags)
> {
> @@ -457,7 +457,7 @@ at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock,
> struct clk_hw *hw;
> int ret;
>
> - if (!name || !(parent_name || parent_hw))
> + if (!name || !(parent_name || parent_data))
> return ERR_PTR(-EINVAL);
>
> periph = kzalloc(sizeof(*periph), GFP_KERNEL);
> @@ -465,8 +465,8 @@ at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock,
> return ERR_PTR(-ENOMEM);
>
> init.name = name;
> - if (parent_hw)
> - init.parent_hws = (const struct clk_hw **)&parent_hw;
> + if (parent_data)
> + init.parent_data = (const struct clk_parent_data *)parent_data;
> else
> init.parent_names = &parent_name;
> init.num_parents = 1;
> diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h
> index b43f6652417f..b6f2aca1e1fd 100644
> --- a/drivers/clk/at91/pmc.h
> +++ b/drivers/clk/at91/pmc.h
> @@ -226,13 +226,13 @@ at91_clk_sama7g5_register_master(struct regmap *regmap,
>
> struct clk_hw * __init
> at91_clk_register_peripheral(struct regmap *regmap, const char *name,
> - const char *parent_name, struct clk_hw *parent_hw,
> + const char *parent_name, struct clk_parent_data *parent_data,
> u32 id);
> struct clk_hw * __init
> at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock,
> const struct clk_pcr_layout *layout,
> const char *name, const char *parent_name,
> - struct clk_hw *parent_hw,
> + struct clk_parent_data *parent_data,
> u32 id, const struct clk_range *range,
> int chg_pid, unsigned long flags);
>
> diff --git a/drivers/clk/at91/sam9x7.c b/drivers/clk/at91/sam9x7.c
> index edd5fd3a1fa5..d7dc5f381ebe 100644
> --- a/drivers/clk/at91/sam9x7.c
> +++ b/drivers/clk/at91/sam9x7.c
> @@ -922,7 +922,7 @@ static void __init sam9x7_pmc_setup(struct device_node *np)
> hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock,
> &sam9x7_pcr_layout,
> sam9x7_periphck[i].n,
> - NULL, sam9x7_pmc->chws[PMC_MCK],
> + NULL, &AT91_CLK_PD_HW(sam9x7_pmc->chws[PMC_MCK]),
> sam9x7_periphck[i].id,
> &range, INT_MIN,
> sam9x7_periphck[i].f);
> diff --git a/drivers/clk/at91/sama7d65.c b/drivers/clk/at91/sama7d65.c
> index 17725c175d3b..372e530f4107 100644
> --- a/drivers/clk/at91/sama7d65.c
> +++ b/drivers/clk/at91/sama7d65.c
> @@ -1306,7 +1306,7 @@ static void __init sama7d65_pmc_setup(struct device_node *np)
> &sama7d65_pcr_layout,
> sama7d65_periphck[i].n,
> NULL,
> - sama7d65_mckx[sama7d65_periphck[i].p].hw,
> + &AT91_CLK_PD_HW(sama7d65_mckx[sama7d65_periphck[i].p].hw),
> sama7d65_periphck[i].id,
> &sama7d65_periphck[i].r,
> sama7d65_periphck[i].chgp ? 0 :
> diff --git a/drivers/clk/at91/sama7g5.c b/drivers/clk/at91/sama7g5.c
> index 733e4fc6a515..f28fe419ae5e 100644
> --- a/drivers/clk/at91/sama7g5.c
> +++ b/drivers/clk/at91/sama7g5.c
> @@ -1181,7 +1181,7 @@ static void __init sama7g5_pmc_setup(struct device_node *np)
> &sama7g5_pcr_layout,
> sama7g5_periphck[i].n,
> NULL,
> - sama7g5_mckx[sama7g5_periphck[i].p].hw,
> + &AT91_CLK_PD_HW(sama7g5_mckx[sama7g5_periphck[i].p].hw),
> sama7g5_periphck[i].id,
> &sama7g5_periphck[i].r,
> sama7g5_periphck[i].chgp ? 0 :