[PATCH v3 01/32] clk: at91: pmc: add macros for clk_parent_data

Ryan.Wanner@microchip.com posted 32 patches 2 months, 4 weeks ago
There is a newer version of this series
[PATCH v3 01/32] clk: at91: pmc: add macros for clk_parent_data
Posted by Ryan.Wanner@microchip.com 2 months, 4 weeks ago
From: Claudiu Beznea <claudiu.beznea@tuxon.dev>

Add helpers to set parent_data objects in platform specific drivers.

Signed-off-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>
[ryan.wanner@microchip.com: enclose complex macro with parentheses.]
Signed-off-by: Ryan Wanner <Ryan.Wanner@microchip.com>
---
 drivers/clk/at91/pmc.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h
index 4fb29ca111f7..0b721a65b77f 100644
--- a/drivers/clk/at91/pmc.h
+++ b/drivers/clk/at91/pmc.h
@@ -15,6 +15,12 @@
 
 #include <dt-bindings/clock/at91.h>
 
+#define AT91_CLK_PD_NAME(n, i) ((struct clk_parent_data){ \
+	.hw = NULL, .name = (n), .fw_name = (n), .index = (i), \
+})
+
+#define AT91_CLK_PD_HW(h) ((struct clk_parent_data){ .hw = (h) })
+
 extern spinlock_t pmc_pcr_lock;
 
 struct pmc_data {
-- 
2.43.0
Re: [PATCH v3 01/32] clk: at91: pmc: add macros for clk_parent_data
Posted by claudiu beznea 1 month ago
Hi, Ryan,

On 7/10/25 23:06, Ryan.Wanner@microchip.com wrote:
> From: Claudiu Beznea <claudiu.beznea@tuxon.dev>
> 
> Add helpers to set parent_data objects in platform specific drivers.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>
> [ryan.wanner@microchip.com: enclose complex macro with parentheses.]
> Signed-off-by: Ryan Wanner <Ryan.Wanner@microchip.com>
> ---
>   drivers/clk/at91/pmc.h | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h
> index 4fb29ca111f7..0b721a65b77f 100644
> --- a/drivers/clk/at91/pmc.h
> +++ b/drivers/clk/at91/pmc.h
> @@ -15,6 +15,12 @@
>   
>   #include <dt-bindings/clock/at91.h>
>   
> +#define AT91_CLK_PD_NAME(n, i) ((struct clk_parent_data){ \
> +	.hw = NULL, .name = (n), .fw_name = (n), .index = (i), \

It's been a while since I worked on this. Looking again at it, having .name
and .fw_name filled with the same data may not be valid all the time.

Moreover, investigating it further I found that we cannot use struct
clk_parent_data::fw_name and struct clk_parent_data::index as the clocks
for these SoCs are registered with CLK_OF_REGISTER() and have no struct
device associated such that dev_or_parent_of_node() (called with
__clk_register()) to return a struct device_node pointer and associated
fw_name code to work properly.

It should have been something like:

#define AT91_CLK_PD_NAME(n) ((struct clk_parent_data){ \
	.hw = NULL, .name = (n), .fw_name = NULL, .index = -1, \
}

> +})
> +
> +#define AT91_CLK_PD_HW(h) ((struct clk_parent_data){ .hw = (h) })

Could you please update this one, something like:

#define AT91_CLK_PD_HW(h) ((struct clk_parent_data){ \
	.hw = (h), .name = NULL, .fw_name = NULL, .index = -1, \
}

Thank you,
Claudiu



> +
>   extern spinlock_t pmc_pcr_lock;
>   
>   struct pmc_data {
Re: [PATCH v3 01/32] clk: at91: pmc: add macros for clk_parent_data
Posted by Stephen Boyd 3 weeks ago
Quoting claudiu beznea (2025-09-06 11:33:34)
> On 7/10/25 23:06, Ryan.Wanner@microchip.com wrote:
> > +})
> > +
> > +#define AT91_CLK_PD_HW(h) ((struct clk_parent_data){ .hw = (h) })
> 
> Could you please update this one, something like:
> 
> #define AT91_CLK_PD_HW(h) ((struct clk_parent_data){ \
>         .hw = (h), .name = NULL, .fw_name = NULL, .index = -1, \
> }

If you're only using a struct clk_hw * then just use clk_hws member and
not clk_parent_data member of struct clk_init_data.
Re: [PATCH v3 01/32] clk: at91: pmc: add macros for clk_parent_data
Posted by Brian Masney 1 month, 1 week ago
On Thu, Jul 10, 2025 at 01:06:54PM -0700, Ryan.Wanner@microchip.com wrote:
> From: Claudiu Beznea <claudiu.beznea@tuxon.dev>
> 
> Add helpers to set parent_data objects in platform specific drivers.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>
> [ryan.wanner@microchip.com: enclose complex macro with parentheses.]
> Signed-off-by: Ryan Wanner <Ryan.Wanner@microchip.com>
> ---
>  drivers/clk/at91/pmc.h | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h
> index 4fb29ca111f7..0b721a65b77f 100644
> --- a/drivers/clk/at91/pmc.h
> +++ b/drivers/clk/at91/pmc.h
> @@ -15,6 +15,12 @@
>  
>  #include <dt-bindings/clock/at91.h>
>  
> +#define AT91_CLK_PD_NAME(n, i) ((struct clk_parent_data){ \
> +	.hw = NULL, .name = (n), .fw_name = (n), .index = (i), \
> +})
> +
> +#define AT91_CLK_PD_HW(h) ((struct clk_parent_data){ .hw = (h) })

If you have to spin a new series, then personally I would put a space
before the {. I see both usages in drivers/clk/.

Reviewed-by: Brian Masney <bmasney@redhat.com>