Skip to content

Commit 8d8c313

Browse files
arndbbebarino
authored andcommitted
clk: define to_clk_regmap() as inline function
Nesting container_of() causes warnings with W=2, which is annoying if it happens in headers and fills the build log like: In file included from drivers/clk/qcom/clk-alpha-pll.c:6: drivers/clk/qcom/clk-alpha-pll.c: In function 'clk_alpha_pll_hwfsm_enable': include/linux/kernel.h:852:8: warning: declaration of '__mptr' shadows a previous local [-Wshadow] 852 | void *__mptr = (void *)(ptr); \ | ^~~~~~ drivers/clk/qcom/clk-alpha-pll.c:155:31: note: in expansion of macro 'container_of' 155 | #define to_clk_alpha_pll(_hw) container_of(to_clk_regmap(_hw), \ | ^~~~~~~~~~~~ drivers/clk/qcom/clk-regmap.h:27:28: note: in expansion of macro 'container_of' 27 | #define to_clk_regmap(_hw) container_of(_hw, struct clk_regmap, hw) | ^~~~~~~~~~~~ drivers/clk/qcom/clk-alpha-pll.c:155:44: note: in expansion of macro 'to_clk_regmap' 155 | #define to_clk_alpha_pll(_hw) container_of(to_clk_regmap(_hw), \ | ^~~~~~~~~~~~~ drivers/clk/qcom/clk-alpha-pll.c:254:30: note: in expansion of macro 'to_clk_alpha_pll' 254 | struct clk_alpha_pll *pll = to_clk_alpha_pll(hw); | ^~~~~~~~~~~~~~~~ include/linux/kernel.h:852:8: note: shadowed declaration is here 852 | void *__mptr = (void *)(ptr); \ | ^~~~~~ Redefine two copies of the to_clk_regmap() macro as inline functions to avoid a lot of these. Fixes: ea11dda ("clk: meson: add regmap clocks") Fixes: 085d7a4 ("clk: qcom: Add a regmap type clock struct") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Link: https://lore.kernel.org/r/20201026161411.3708639-1-arnd@kernel.org Acked-by: Jerome Brunet <jbrunet@baylibre.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 3650b22 commit 8d8c313

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

drivers/clk/meson/clk-regmap.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ struct clk_regmap {
2626
void *data;
2727
};
2828

29-
#define to_clk_regmap(_hw) container_of(_hw, struct clk_regmap, hw)
29+
static inline struct clk_regmap *to_clk_regmap(struct clk_hw *hw)
30+
{
31+
return container_of(hw, struct clk_regmap, hw);
32+
}
3033

3134
/**
3235
* struct clk_regmap_gate_data - regmap backed gate specific data

drivers/clk/qcom/clk-regmap.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ struct clk_regmap {
2424
unsigned int enable_mask;
2525
bool enable_is_inverted;
2626
};
27-
#define to_clk_regmap(_hw) container_of(_hw, struct clk_regmap, hw)
27+
28+
static inline struct clk_regmap *to_clk_regmap(struct clk_hw *hw)
29+
{
30+
return container_of(hw, struct clk_regmap, hw);
31+
}
2832

2933
int clk_is_enabled_regmap(struct clk_hw *hw);
3034
int clk_enable_regmap(struct clk_hw *hw);

0 commit comments

Comments
 (0)