Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: mux: Add hw based registration APIs

Add registration APIs in the clk mux code to return struct clk_hw
pointers instead of struct clk pointers. This way we hide the
struct clk pointer from providers unless they need to use
consumer facing APIs.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

+62 -6
+51 -6
drivers/clk/clk-mux.c
··· 113 113 }; 114 114 EXPORT_SYMBOL_GPL(clk_mux_ro_ops); 115 115 116 - struct clk *clk_register_mux_table(struct device *dev, const char *name, 116 + struct clk_hw *clk_hw_register_mux_table(struct device *dev, const char *name, 117 117 const char * const *parent_names, u8 num_parents, 118 118 unsigned long flags, 119 119 void __iomem *reg, u8 shift, u32 mask, 120 120 u8 clk_mux_flags, u32 *table, spinlock_t *lock) 121 121 { 122 122 struct clk_mux *mux; 123 - struct clk *clk; 123 + struct clk_hw *hw; 124 124 struct clk_init_data init; 125 125 u8 width = 0; 126 + int ret; 126 127 127 128 if (clk_mux_flags & CLK_MUX_HIWORD_MASK) { 128 129 width = fls(mask) - ffs(mask) + 1; ··· 158 157 mux->table = table; 159 158 mux->hw.init = &init; 160 159 161 - clk = clk_register(dev, &mux->hw); 162 - 163 - if (IS_ERR(clk)) 160 + hw = &mux->hw; 161 + ret = clk_hw_register(dev, hw); 162 + if (ret) { 164 163 kfree(mux); 164 + hw = ERR_PTR(ret); 165 + } 165 166 166 - return clk; 167 + return hw; 168 + } 169 + EXPORT_SYMBOL_GPL(clk_hw_register_mux_table); 170 + 171 + struct clk *clk_register_mux_table(struct device *dev, const char *name, 172 + const char * const *parent_names, u8 num_parents, 173 + unsigned long flags, 174 + void __iomem *reg, u8 shift, u32 mask, 175 + u8 clk_mux_flags, u32 *table, spinlock_t *lock) 176 + { 177 + struct clk_hw *hw; 178 + 179 + hw = clk_hw_register_mux_table(dev, name, parent_names, num_parents, 180 + flags, reg, shift, mask, clk_mux_flags, 181 + table, lock); 182 + if (IS_ERR(hw)) 183 + return ERR_CAST(hw); 184 + return hw->clk; 167 185 } 168 186 EXPORT_SYMBOL_GPL(clk_register_mux_table); 169 187 ··· 200 180 } 201 181 EXPORT_SYMBOL_GPL(clk_register_mux); 202 182 183 + struct clk_hw *clk_hw_register_mux(struct device *dev, const char *name, 184 + const char * const *parent_names, u8 num_parents, 185 + unsigned long flags, 186 + void __iomem *reg, u8 shift, u8 width, 187 + u8 clk_mux_flags, spinlock_t *lock) 188 + { 189 + u32 mask = BIT(width) - 1; 190 + 191 + return clk_hw_register_mux_table(dev, name, parent_names, num_parents, 192 + flags, reg, shift, mask, clk_mux_flags, 193 + NULL, lock); 194 + } 195 + EXPORT_SYMBOL_GPL(clk_hw_register_mux); 196 + 203 197 void clk_unregister_mux(struct clk *clk) 204 198 { 205 199 struct clk_mux *mux; ··· 229 195 kfree(mux); 230 196 } 231 197 EXPORT_SYMBOL_GPL(clk_unregister_mux); 198 + 199 + void clk_hw_unregister_mux(struct clk_hw *hw) 200 + { 201 + struct clk_mux *mux; 202 + 203 + mux = to_clk_mux(hw); 204 + 205 + clk_hw_unregister(hw); 206 + kfree(mux); 207 + } 208 + EXPORT_SYMBOL_GPL(clk_hw_unregister_mux);
+11
include/linux/clk-provider.h
··· 478 478 unsigned long flags, 479 479 void __iomem *reg, u8 shift, u8 width, 480 480 u8 clk_mux_flags, spinlock_t *lock); 481 + struct clk_hw *clk_hw_register_mux(struct device *dev, const char *name, 482 + const char * const *parent_names, u8 num_parents, 483 + unsigned long flags, 484 + void __iomem *reg, u8 shift, u8 width, 485 + u8 clk_mux_flags, spinlock_t *lock); 481 486 482 487 struct clk *clk_register_mux_table(struct device *dev, const char *name, 483 488 const char * const *parent_names, u8 num_parents, 484 489 unsigned long flags, 485 490 void __iomem *reg, u8 shift, u32 mask, 486 491 u8 clk_mux_flags, u32 *table, spinlock_t *lock); 492 + struct clk_hw *clk_hw_register_mux_table(struct device *dev, const char *name, 493 + const char * const *parent_names, u8 num_parents, 494 + unsigned long flags, 495 + void __iomem *reg, u8 shift, u32 mask, 496 + u8 clk_mux_flags, u32 *table, spinlock_t *lock); 487 497 488 498 void clk_unregister_mux(struct clk *clk); 499 + void clk_hw_unregister_mux(struct clk_hw *hw); 489 500 490 501 void of_fixed_factor_clk_setup(struct device_node *node); 491 502