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

clk: mux: provide devm_clk_hw_register_mux()

Add devm_clk_hw_register_mux() - devres-managed version of
clk_hw_register_mux().

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Abhinav Kumar <abhinavk@codeaurora.org>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20210331105735.3690009-2-dmitry.baryshkov@linaro.org
Signed-off-by: Rob Clark <robdclark@chromium.org>

authored by

Dmitry Baryshkov and committed by
Rob Clark
b3084079 cb3fd74a

+48
+35
drivers/clk/clk-mux.c
··· 8 8 */ 9 9 10 10 #include <linux/clk-provider.h> 11 + #include <linux/device.h> 11 12 #include <linux/module.h> 12 13 #include <linux/slab.h> 13 14 #include <linux/io.h> ··· 206 205 return hw; 207 206 } 208 207 EXPORT_SYMBOL_GPL(__clk_hw_register_mux); 208 + 209 + static void devm_clk_hw_release_mux(struct device *dev, void *res) 210 + { 211 + clk_hw_unregister_mux(*(struct clk_hw **)res); 212 + } 213 + 214 + struct clk_hw *__devm_clk_hw_register_mux(struct device *dev, struct device_node *np, 215 + const char *name, u8 num_parents, 216 + const char * const *parent_names, 217 + const struct clk_hw **parent_hws, 218 + const struct clk_parent_data *parent_data, 219 + unsigned long flags, void __iomem *reg, u8 shift, u32 mask, 220 + u8 clk_mux_flags, u32 *table, spinlock_t *lock) 221 + { 222 + struct clk_hw **ptr, *hw; 223 + 224 + ptr = devres_alloc(devm_clk_hw_release_mux, sizeof(*ptr), GFP_KERNEL); 225 + if (!ptr) 226 + return ERR_PTR(-ENOMEM); 227 + 228 + hw = __clk_hw_register_mux(dev, np, name, num_parents, parent_names, parent_hws, 229 + parent_data, flags, reg, shift, mask, 230 + clk_mux_flags, table, lock); 231 + 232 + if (!IS_ERR(hw)) { 233 + *ptr = hw; 234 + devres_add(dev, ptr); 235 + } else { 236 + devres_free(ptr); 237 + } 238 + 239 + return hw; 240 + } 241 + EXPORT_SYMBOL_GPL(__devm_clk_hw_register_mux); 209 242 210 243 struct clk *clk_register_mux_table(struct device *dev, const char *name, 211 244 const char * const *parent_names, u8 num_parents,
+13
include/linux/clk-provider.h
··· 868 868 const struct clk_parent_data *parent_data, 869 869 unsigned long flags, void __iomem *reg, u8 shift, u32 mask, 870 870 u8 clk_mux_flags, u32 *table, spinlock_t *lock); 871 + struct clk_hw *__devm_clk_hw_register_mux(struct device *dev, struct device_node *np, 872 + const char *name, u8 num_parents, 873 + const char * const *parent_names, 874 + const struct clk_hw **parent_hws, 875 + const struct clk_parent_data *parent_data, 876 + unsigned long flags, void __iomem *reg, u8 shift, u32 mask, 877 + u8 clk_mux_flags, u32 *table, spinlock_t *lock); 871 878 struct clk *clk_register_mux_table(struct device *dev, const char *name, 872 879 const char * const *parent_names, u8 num_parents, 873 880 unsigned long flags, void __iomem *reg, u8 shift, u32 mask, ··· 909 902 __clk_hw_register_mux((dev), NULL, (name), (num_parents), NULL, NULL, \ 910 903 (parent_data), (flags), (reg), (shift), \ 911 904 BIT((width)) - 1, (clk_mux_flags), NULL, (lock)) 905 + #define devm_clk_hw_register_mux(dev, name, parent_names, num_parents, flags, reg, \ 906 + shift, width, clk_mux_flags, lock) \ 907 + __devm_clk_hw_register_mux((dev), NULL, (name), (num_parents), \ 908 + (parent_names), NULL, NULL, (flags), (reg), \ 909 + (shift), BIT((width)) - 1, (clk_mux_flags), \ 910 + NULL, (lock)) 912 911 913 912 int clk_mux_val_to_index(struct clk_hw *hw, u32 *table, unsigned int flags, 914 913 unsigned int val);