clk: No-op CLK_OF_DECLARE if not enabled
Subsystems (2)
PATCH v2 1/1 clk: No-op CLK_OF_DECLARE if not enabled
Instead of wrapping each defenition of CLK_OF_DECLARE hook with preprocessor guards, change the definition of CLK_OF_DECLARE to expand into no-op if COMMON_CLK_OF_PROVIDER is not enabled.
Signed-off-by Andrey Smirnov <[email protected]>
--- drivers/clk/clk-fixed-factor.c | 2 -- drivers/clk/clk-fixed.c | 3 +-- include/linux/clk.h | 31 +++++++++++++++++++++++++------ 3 files changed, 26 insertions(+), 10 deletions(-)
drivers/clk/clk-fixed-factor.c +0 -2
@@ -93,7 +93,6 @@ struct clk *clk_fixed_factor(const char *name,return &f->clk; } -#if defined(CONFIG_COMMON_CLK_OF_PROVIDER )/** * of_fixed_factor_clk_setup() - Setup function for simple fixed factor clock */
@@ -127,4 +126,3 @@ static int of_fixed_factor_clk_setup(struct device_node *node) }CLK_OF_DECLARE (fixed_factor_clk,"fixed-factor-clock" , of_fixed_factor_clk_setup); -#endif
drivers/clk/clk-fixed.c +1 -2
@@ -55,7 +55,6 @@ struct clk *clk_fixed(const char *name, int rate)return &fix->clk; } -#if defined(CONFIG_COMMON_CLK_OF_PROVIDER )/** * of_fixed_clk_setup() - Setup function for simple fixed rate clock */
@@ -76,4 +75,4 @@ static int of_fixed_clk_setup(struct device_node *node)return of_clk_add_provider (node, of_clk_src_simple_get, clk); }CLK_OF_DECLARE (fixed_clk,"fixed-clock" , of_fixed_clk_setup); -#endif +
include/linux/clk.h +25 -6
@@ -324,16 +324,13 @@ struct clk *clk_register_composite(const char *name,struct device_node ;struct of_phandle_args ; +#if defined(CONFIG_COMMON_CLK_OF_PROVIDER ) +#define CLK_OF_DECLARE (name, compat, fn) \ const struct of_device_id __clk_of_table_##name \ __attribute__ ((unused,section (".__clk_of_table"))) \ = { .compatible = compat, .data = fn } -#if defined(CONFIG_COMMON_CLK_OF_PROVIDER ) -int of_clk_add_provider (struct device_node *np, -struct clk *(*clk_src_get)(struct of_phandle_args *args, -void *data), -void *data);void of_clk_del_provider (struct device_node *np);typedef int (*of_clk_init_cb_t )(struct device_node *);
@@ -349,11 +346,27 @@ struct clk *of_clk_get(struct device_node *np, int index);struct clk *of_clk_get_by_name (struct device_node *np,const char *name);struct clk *of_clk_get_from_provider (struct of_phandle_args *clkspec);unsigned int of_clk_get_parent_count (struct device_node *np); -char *of_clk_get_parent_name (struct device_node *np,unsigned int index);int of_clk_parent_fill (struct device_node *np,const char **parents,unsigned int size);int of_clk_init (struct device_node *root,const struct of_device_id *matches);#else + + +/* +* Create a dummy variable to avoid 'unused function' +* warnings. Compiler should be smart enough to throw it out. +*/ +#define CLK_OF_DECLARE (name, compat, fn) \ +static const struct of_device_id __clk_of_table_##name \ +__attribute__ ((unused)) = { .data = fn } + + +static inline struct clk * +of_clk_src_simple_get (struct of_phandle_args *clkspec,void *data) +{ +return ERR_PTR (-ENOENT ); +} +static inline struct clk *of_clk_get (struct device_node *np,int index) {return ERR_PTR (-ENOENT );
@@ -374,4 +387,10 @@ struct string_list;int clk_name_complete (struct string_list *sl,char *instr); +int of_clk_add_provider (struct device_node *np, +struct clk *(*clk_src_get)(struct of_phandle_args *args, +void *data), +void *data); +char *of_clk_get_parent_name (struct device_node *np,unsigned int index); +#endif
Signature · 7 lines
2.9.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 10 lines · Andrey Smirnov
Instead of wrapping each defenition of
CLK_OF_DECLAREhook with preprocessor guards, change the definition ofCLK_OF_DECLAREto expand into no-op ifCOMMON_CLK_OF_PROVIDERis not enabled.Signed-off-by Andrey Smirnov <[email protected]>--- drivers/clk/clk-fixed-factor.c | 2 -- drivers/clk/clk-fixed.c | 3 +-- include/linux/clk.h | 31 +++++++++++++++++++++++++------ 3 files changed, 26 insertions(+), 10 deletions(-)
Applied, thanks
Sascha
Quoted 108 lines
drivers/clk/clk-fixed-factor.c +0
-2@@ -93,7 +93,6 @@ struct clk *clk_fixed_factor(const char *name,return &f->clk; } -#if defined(CONFIG_COMMON_CLK_OF_PROVIDER )/** * of_fixed_factor_clk_setup() - Setup function for simple fixed factor clock */ @@ -127,4 +126,3 @@ static int of_fixed_factor_clk_setup(struct device_node *node) }CLK_OF_DECLARE (fixed_factor_clk,"fixed-factor-clock" , of_fixed_factor_clk_setup); -#endif drivers/clk/clk-fixed.c +1
-2@@ -55,7 +55,6 @@ struct clk *clk_fixed(const char *name, int rate)return &fix->clk; } -#if defined(CONFIG_COMMON_CLK_OF_PROVIDER )/** * of_fixed_clk_setup() - Setup function for simple fixed rate clock */ @@ -76,4 +75,4 @@ static int of_fixed_clk_setup(struct device_node *node)return of_clk_add_provider (node, of_clk_src_simple_get, clk); }CLK_OF_DECLARE (fixed_clk,"fixed-clock" , of_fixed_clk_setup); -#endif +include/linux/clk.h +25
-6@@ -324,16 +324,13 @@ struct clk *clk_register_composite(const char *name,struct device_node ;struct of_phandle_args ; +#if defined(CONFIG_COMMON_CLK_OF_PROVIDER ) +#define CLK_OF_DECLARE (name, compat, fn) \ const struct of_device_id __clk_of_table_##name \ __attribute__ ((unused,section (".__clk_of_table"))) \ = { .compatible = compat, .data = fn } -#if defined(CONFIG_COMMON_CLK_OF_PROVIDER ) -int of_clk_add_provider (struct device_node *np, -struct clk *(*clk_src_get)(struct of_phandle_args *args, -void *data), -void *data);void of_clk_del_provider (struct device_node *np);typedef int (*of_clk_init_cb_t )(struct device_node *);@@ -349,11 +346,27 @@ struct clk *of_clk_get(struct device_node *np, int index);struct clk *of_clk_get_by_name (struct device_node *np,const char *name);struct clk *of_clk_get_from_provider (struct of_phandle_args *clkspec);unsigned int of_clk_get_parent_count (struct device_node *np); -char *of_clk_get_parent_name (struct device_node *np,unsigned int index);int of_clk_parent_fill (struct device_node *np,const char **parents,unsigned int size);int of_clk_init (struct device_node *root,const struct of_device_id *matches);#else + + +/* +* Create a dummy variable to avoid 'unused function' +* warnings. Compiler should be smart enough to throw it out. +*/ +#define CLK_OF_DECLARE (name, compat, fn) \ +static const struct of_device_id __clk_of_table_##name \ +__attribute__ ((unused)) = { .data = fn } + + +static inline struct clk * +of_clk_src_simple_get (struct of_phandle_args *clkspec,void *data) +{ +return ERR_PTR (-ENOENT ); +} +static inline struct clk *of_clk_get (struct device_node *np,int index) {return ERR_PTR (-ENOENT );@@ -374,4 +387,10 @@ struct string_list;int clk_name_complete (struct string_list *sl,char *instr); +int of_clk_add_provider (struct device_node *np, +struct clk *(*clk_src_get)(struct of_phandle_args *args, +void *data), +void *data); +char *of_clk_get_parent_name (struct device_node *np,unsigned int index); +#endif Signature · 7 lines
2.9.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox