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

clk: fixed-factor: Add hw based registration APIs

Add registration APIs in the clk fixed-factor 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>

+39 -7
+35 -7
drivers/clk/clk-fixed-factor.c
··· 68 68 }; 69 69 EXPORT_SYMBOL_GPL(clk_fixed_factor_ops); 70 70 71 - struct clk *clk_register_fixed_factor(struct device *dev, const char *name, 72 - const char *parent_name, unsigned long flags, 71 + struct clk_hw *clk_hw_register_fixed_factor(struct device *dev, 72 + const char *name, const char *parent_name, unsigned long flags, 73 73 unsigned int mult, unsigned int div) 74 74 { 75 75 struct clk_fixed_factor *fix; 76 76 struct clk_init_data init; 77 - struct clk *clk; 77 + struct clk_hw *hw; 78 + int ret; 78 79 79 80 fix = kmalloc(sizeof(*fix), GFP_KERNEL); 80 81 if (!fix) ··· 92 91 init.parent_names = &parent_name; 93 92 init.num_parents = 1; 94 93 95 - clk = clk_register(dev, &fix->hw); 96 - 97 - if (IS_ERR(clk)) 94 + hw = &fix->hw; 95 + ret = clk_hw_register(dev, hw); 96 + if (ret) { 98 97 kfree(fix); 98 + hw = ERR_PTR(ret); 99 + } 99 100 100 - return clk; 101 + return hw; 102 + } 103 + EXPORT_SYMBOL_GPL(clk_hw_register_fixed_factor); 104 + 105 + struct clk *clk_register_fixed_factor(struct device *dev, const char *name, 106 + const char *parent_name, unsigned long flags, 107 + unsigned int mult, unsigned int div) 108 + { 109 + struct clk_hw *hw; 110 + 111 + hw = clk_hw_register_fixed_factor(dev, name, parent_name, flags, mult, 112 + div); 113 + if (IS_ERR(hw)) 114 + return ERR_CAST(hw); 115 + return hw->clk; 101 116 } 102 117 EXPORT_SYMBOL_GPL(clk_register_fixed_factor); 103 118 ··· 129 112 kfree(to_clk_fixed_factor(hw)); 130 113 } 131 114 EXPORT_SYMBOL_GPL(clk_unregister_fixed_factor); 115 + 116 + void clk_hw_unregister_fixed_factor(struct clk_hw *hw) 117 + { 118 + struct clk_fixed_factor *fix; 119 + 120 + fix = to_clk_fixed_factor(hw); 121 + 122 + clk_hw_unregister(hw); 123 + kfree(fix); 124 + } 125 + EXPORT_SYMBOL_GPL(clk_hw_unregister_fixed_factor); 132 126 133 127 #ifdef CONFIG_OF 134 128 /**
+4
include/linux/clk-provider.h
··· 525 525 const char *parent_name, unsigned long flags, 526 526 unsigned int mult, unsigned int div); 527 527 void clk_unregister_fixed_factor(struct clk *clk); 528 + struct clk_hw *clk_hw_register_fixed_factor(struct device *dev, 529 + const char *name, const char *parent_name, unsigned long flags, 530 + unsigned int mult, unsigned int div); 531 + void clk_hw_unregister_fixed_factor(struct clk_hw *hw); 528 532 529 533 /** 530 534 * struct clk_fractional_divider - adjustable fractional divider clock