linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: avoid build failure on CLK_OF_DECLARE() with invalid name
@ 2023-03-10 14:02 Arnd Bergmann
  2023-03-10 17:21 ` Saravana Kannan
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2023-03-10 14:02 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Ricardo Ribalda,
	Saravana Kannan, Linus Walleij
  Cc: Arnd Bergmann, Maxime Ripard, Dmitry Baryshkov, Marijn Suijten,
	Bjorn Andersson, Andy Shevchenko, Christian Marangi, linux-clk,
	linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

Generating an init function function from CLK_OF_DECLARE() broke for the
98dx1135_clk declaration because that string starts with a digit and
is not a valid C identifier:

In file included from drivers/clk/mvebu/kirkwood.c:15:
drivers/clk/mvebu/kirkwood.c:358:16: error: invalid suffix "dx1135_clk_of_clk_init_declare" on integer constant
  358 | CLK_OF_DECLARE(98dx1135_clk, "marvell,mv98dx1135-core-clock",
      |                ^~~~~~~~~~~~
include/linux/clk-provider.h:1367:28: note: in definition of macro 'CLK_OF_DECLARE'
 1367 |         static void __init name##_of_clk_init_declare(struct device_node *np) \
      |                            ^~~~
drivers/clk/mvebu/kirkwood.c:358:16: error: expected identifier or '(' before numeric constant
  358 | CLK_OF_DECLARE(98dx1135_clk, "marvell,mv98dx1135-core-clock",
      |                ^~~~~~~~~~~~
include/linux/clk-provider.h:1367:28: note: in definition of macro 'CLK_OF_DECLARE'
 1367 |         static void __init name##_of_clk_init_declare(struct device_node *np) \
      |                            ^~~~

This could be fixed in the driver by renaming 98dx1135_clk to a valid
C identifier, but it's easy enough to make the macro more robust by
reversing the two parts of the name, which makes it work for other files
that may have the same issue. Since CLK_OF_DECLARE_DRIVER() has a very
similar definition, do the same change in both.

Fixes: c7296c51ce5d ("clk: core: New macro CLK_OF_DECLARE_DRIVER")
Fixes: c28cd1f3433c ("clk: Mark a fwnode as initialized when using CLK_OF_DECLARE() macro")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 include/linux/clk-provider.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index c9f5276006a0..3586a029db05 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -1364,24 +1364,24 @@ struct clk_hw_onecell_data {
 };
 
 #define CLK_OF_DECLARE(name, compat, fn) \
-	static void __init name##_of_clk_init_declare(struct device_node *np) \
+	static void __init of_clk_init_declare##name(struct device_node *np) \
 	{								\
 		fn(np);							\
 		fwnode_dev_initialized(of_fwnode_handle(np), true);	\
 	}								\
-	OF_DECLARE_1(clk, name, compat, name##_of_clk_init_declare)
+	OF_DECLARE_1(clk, name, compat, of_clk_init_declare##name)
 
 /*
  * Use this macro when you have a driver that requires two initialization
  * routines, one at of_clk_init(), and one at platform device probe
  */
 #define CLK_OF_DECLARE_DRIVER(name, compat, fn) \
-	static void __init name##_of_clk_init_driver(struct device_node *np) \
+	static void __init of_clk_init_driver##name(struct device_node *np) \
 	{								\
 		of_node_clear_flag(np, OF_POPULATED);			\
 		fn(np);							\
 	}								\
-	OF_DECLARE_1(clk, name, compat, name##_of_clk_init_driver)
+	OF_DECLARE_1(clk, name, compat, of_clk_init_driver##name)
 
 #define CLK_HW_INIT(_name, _parent, _ops, _flags)		\
 	(&(struct clk_init_data) {				\
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] clk: avoid build failure on CLK_OF_DECLARE() with invalid name
  2023-03-10 14:02 [PATCH] clk: avoid build failure on CLK_OF_DECLARE() with invalid name Arnd Bergmann
@ 2023-03-10 17:21 ` Saravana Kannan
  0 siblings, 0 replies; 2+ messages in thread
From: Saravana Kannan @ 2023-03-10 17:21 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Michael Turquette, Stephen Boyd, Ricardo Ribalda, Linus Walleij,
	Arnd Bergmann, Maxime Ripard, Dmitry Baryshkov, Marijn Suijten,
	Bjorn Andersson, Andy Shevchenko, Christian Marangi, linux-clk,
	linux-kernel

On Fri, Mar 10, 2023 at 6:02 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> Generating an init function function from CLK_OF_DECLARE() broke for the
> 98dx1135_clk declaration because that string starts with a digit and
> is not a valid C identifier:

Nathan already sent out a fix for this and it's been picked up.

https://lore.kernel.org/lkml/20230308-clk_of_declare-fix-v1-1-317b741e2532@kernel.org/

-Saravana

>
> In file included from drivers/clk/mvebu/kirkwood.c:15:
> drivers/clk/mvebu/kirkwood.c:358:16: error: invalid suffix "dx1135_clk_of_clk_init_declare" on integer constant
>   358 | CLK_OF_DECLARE(98dx1135_clk, "marvell,mv98dx1135-core-clock",
>       |                ^~~~~~~~~~~~
> include/linux/clk-provider.h:1367:28: note: in definition of macro 'CLK_OF_DECLARE'
>  1367 |         static void __init name##_of_clk_init_declare(struct device_node *np) \
>       |                            ^~~~
> drivers/clk/mvebu/kirkwood.c:358:16: error: expected identifier or '(' before numeric constant
>   358 | CLK_OF_DECLARE(98dx1135_clk, "marvell,mv98dx1135-core-clock",
>       |                ^~~~~~~~~~~~
> include/linux/clk-provider.h:1367:28: note: in definition of macro 'CLK_OF_DECLARE'
>  1367 |         static void __init name##_of_clk_init_declare(struct device_node *np) \
>       |                            ^~~~
>
> This could be fixed in the driver by renaming 98dx1135_clk to a valid
> C identifier, but it's easy enough to make the macro more robust by
> reversing the two parts of the name, which makes it work for other files
> that may have the same issue. Since CLK_OF_DECLARE_DRIVER() has a very
> similar definition, do the same change in both.
>
> Fixes: c7296c51ce5d ("clk: core: New macro CLK_OF_DECLARE_DRIVER")
> Fixes: c28cd1f3433c ("clk: Mark a fwnode as initialized when using CLK_OF_DECLARE() macro")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  include/linux/clk-provider.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
> index c9f5276006a0..3586a029db05 100644
> --- a/include/linux/clk-provider.h
> +++ b/include/linux/clk-provider.h
> @@ -1364,24 +1364,24 @@ struct clk_hw_onecell_data {
>  };
>
>  #define CLK_OF_DECLARE(name, compat, fn) \
> -       static void __init name##_of_clk_init_declare(struct device_node *np) \
> +       static void __init of_clk_init_declare##name(struct device_node *np) \
>         {                                                               \
>                 fn(np);                                                 \
>                 fwnode_dev_initialized(of_fwnode_handle(np), true);     \
>         }                                                               \
> -       OF_DECLARE_1(clk, name, compat, name##_of_clk_init_declare)
> +       OF_DECLARE_1(clk, name, compat, of_clk_init_declare##name)
>
>  /*
>   * Use this macro when you have a driver that requires two initialization
>   * routines, one at of_clk_init(), and one at platform device probe
>   */
>  #define CLK_OF_DECLARE_DRIVER(name, compat, fn) \
> -       static void __init name##_of_clk_init_driver(struct device_node *np) \
> +       static void __init of_clk_init_driver##name(struct device_node *np) \
>         {                                                               \
>                 of_node_clear_flag(np, OF_POPULATED);                   \
>                 fn(np);                                                 \
>         }                                                               \
> -       OF_DECLARE_1(clk, name, compat, name##_of_clk_init_driver)
> +       OF_DECLARE_1(clk, name, compat, of_clk_init_driver##name)
>
>  #define CLK_HW_INIT(_name, _parent, _ops, _flags)              \
>         (&(struct clk_init_data) {                              \
> --
> 2.39.2
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-10 17:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-10 14:02 [PATCH] clk: avoid build failure on CLK_OF_DECLARE() with invalid name Arnd Bergmann
2023-03-10 17:21 ` Saravana Kannan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).