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

clk: fractional-divider: Add hw based registration APIs

Add registration APIs in the clk fractional divider 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>

+40 -5
+35 -5
drivers/clk/clk-fractional-divider.c
··· 116 116 }; 117 117 EXPORT_SYMBOL_GPL(clk_fractional_divider_ops); 118 118 119 - struct clk *clk_register_fractional_divider(struct device *dev, 119 + struct clk_hw *clk_hw_register_fractional_divider(struct device *dev, 120 120 const char *name, const char *parent_name, unsigned long flags, 121 121 void __iomem *reg, u8 mshift, u8 mwidth, u8 nshift, u8 nwidth, 122 122 u8 clk_divider_flags, spinlock_t *lock) 123 123 { 124 124 struct clk_fractional_divider *fd; 125 125 struct clk_init_data init; 126 - struct clk *clk; 126 + struct clk_hw *hw; 127 + int ret; 127 128 128 129 fd = kzalloc(sizeof(*fd), GFP_KERNEL); 129 130 if (!fd) ··· 147 146 fd->lock = lock; 148 147 fd->hw.init = &init; 149 148 150 - clk = clk_register(dev, &fd->hw); 151 - if (IS_ERR(clk)) 149 + hw = &fd->hw; 150 + ret = clk_hw_register(dev, hw); 151 + if (ret) { 152 152 kfree(fd); 153 + hw = ERR_PTR(ret); 154 + } 153 155 154 - return clk; 156 + return hw; 157 + } 158 + EXPORT_SYMBOL_GPL(clk_hw_register_fractional_divider); 159 + 160 + struct clk *clk_register_fractional_divider(struct device *dev, 161 + const char *name, const char *parent_name, unsigned long flags, 162 + void __iomem *reg, u8 mshift, u8 mwidth, u8 nshift, u8 nwidth, 163 + u8 clk_divider_flags, spinlock_t *lock) 164 + { 165 + struct clk_hw *hw; 166 + 167 + hw = clk_hw_register_fractional_divider(dev, name, parent_name, flags, 168 + reg, mshift, mwidth, nshift, nwidth, clk_divider_flags, 169 + lock); 170 + if (IS_ERR(hw)) 171 + return ERR_CAST(hw); 172 + return hw->clk; 155 173 } 156 174 EXPORT_SYMBOL_GPL(clk_register_fractional_divider); 175 + 176 + void clk_hw_unregister_fractional_divider(struct clk_hw *hw) 177 + { 178 + struct clk_fractional_divider *fd; 179 + 180 + fd = to_clk_fd(hw); 181 + 182 + clk_hw_unregister(hw); 183 + kfree(fd); 184 + }
+5
include/linux/clk-provider.h
··· 563 563 const char *name, const char *parent_name, unsigned long flags, 564 564 void __iomem *reg, u8 mshift, u8 mwidth, u8 nshift, u8 nwidth, 565 565 u8 clk_divider_flags, spinlock_t *lock); 566 + struct clk_hw *clk_hw_register_fractional_divider(struct device *dev, 567 + const char *name, const char *parent_name, unsigned long flags, 568 + void __iomem *reg, u8 mshift, u8 mwidth, u8 nshift, u8 nwidth, 569 + u8 clk_divider_flags, spinlock_t *lock); 570 + void clk_hw_unregister_fractional_divider(struct clk_hw *hw); 566 571 567 572 /** 568 573 * struct clk_multiplier - adjustable multiplier clock