diff options
author | Stephen Boyd <sboyd@codeaurora.org> | 2016-02-07 03:27:55 -0500 |
---|---|---|
committer | Stephen Boyd <sboyd@codeaurora.org> | 2016-04-19 19:56:28 -0400 |
commit | b120743a64a3ec68b8c5310a6009094329b4a33b (patch) | |
tree | 35603a4df0e4a6a699b19c5eb3a3558ffa04590a /drivers/clk | |
parent | 49cb392d36397a296dcd51ec57cf83585a89a94a (diff) |
clk: gpio: Add hw based registration APIs
Add registration APIs in the clk gpio 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>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk-gpio.c | 52 |
1 files changed, 41 insertions, 11 deletions
diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c index 08f65acc5d57..86b245746a6b 100644 --- a/drivers/clk/clk-gpio.c +++ b/drivers/clk/clk-gpio.c | |||
@@ -94,13 +94,13 @@ const struct clk_ops clk_gpio_mux_ops = { | |||
94 | }; | 94 | }; |
95 | EXPORT_SYMBOL_GPL(clk_gpio_mux_ops); | 95 | EXPORT_SYMBOL_GPL(clk_gpio_mux_ops); |
96 | 96 | ||
97 | static struct clk *clk_register_gpio(struct device *dev, const char *name, | 97 | static struct clk_hw *clk_register_gpio(struct device *dev, const char *name, |
98 | const char * const *parent_names, u8 num_parents, unsigned gpio, | 98 | const char * const *parent_names, u8 num_parents, unsigned gpio, |
99 | bool active_low, unsigned long flags, | 99 | bool active_low, unsigned long flags, |
100 | const struct clk_ops *clk_gpio_ops) | 100 | const struct clk_ops *clk_gpio_ops) |
101 | { | 101 | { |
102 | struct clk_gpio *clk_gpio; | 102 | struct clk_gpio *clk_gpio; |
103 | struct clk *clk; | 103 | struct clk_hw *hw; |
104 | struct clk_init_data init = {}; | 104 | struct clk_init_data init = {}; |
105 | unsigned long gpio_flags; | 105 | unsigned long gpio_flags; |
106 | int err; | 106 | int err; |
@@ -141,24 +141,26 @@ static struct clk *clk_register_gpio(struct device *dev, const char *name, | |||
141 | clk_gpio->gpiod = gpio_to_desc(gpio); | 141 | clk_gpio->gpiod = gpio_to_desc(gpio); |
142 | clk_gpio->hw.init = &init; | 142 | clk_gpio->hw.init = &init; |
143 | 143 | ||
144 | hw = &clk_gpio->hw; | ||
144 | if (dev) | 145 | if (dev) |
145 | clk = devm_clk_register(dev, &clk_gpio->hw); | 146 | err = devm_clk_hw_register(dev, hw); |
146 | else | 147 | else |
147 | clk = clk_register(NULL, &clk_gpio->hw); | 148 | err = clk_hw_register(NULL, hw); |
148 | 149 | ||
149 | if (!IS_ERR(clk)) | 150 | if (!err) |
150 | return clk; | 151 | return hw; |
151 | 152 | ||
152 | if (!dev) { | 153 | if (!dev) { |
153 | gpiod_put(clk_gpio->gpiod); | 154 | gpiod_put(clk_gpio->gpiod); |
154 | kfree(clk_gpio); | 155 | kfree(clk_gpio); |
155 | } | 156 | } |
156 | 157 | ||
157 | return clk; | 158 | return ERR_PTR(err); |
158 | } | 159 | } |
159 | 160 | ||
160 | /** | 161 | /** |
161 | * clk_register_gpio_gate - register a gpio clock gate with the clock framework | 162 | * clk_hw_register_gpio_gate - register a gpio clock gate with the clock |
163 | * framework | ||
162 | * @dev: device that is registering this clock | 164 | * @dev: device that is registering this clock |
163 | * @name: name of this clock | 165 | * @name: name of this clock |
164 | * @parent_name: name of this clock's parent | 166 | * @parent_name: name of this clock's parent |
@@ -166,7 +168,7 @@ static struct clk *clk_register_gpio(struct device *dev, const char *name, | |||
166 | * @active_low: true if gpio should be set to 0 to enable clock | 168 | * @active_low: true if gpio should be set to 0 to enable clock |
167 | * @flags: clock flags | 169 | * @flags: clock flags |
168 | */ | 170 | */ |
169 | struct clk *clk_register_gpio_gate(struct device *dev, const char *name, | 171 | struct clk_hw *clk_hw_register_gpio_gate(struct device *dev, const char *name, |
170 | const char *parent_name, unsigned gpio, bool active_low, | 172 | const char *parent_name, unsigned gpio, bool active_low, |
171 | unsigned long flags) | 173 | unsigned long flags) |
172 | { | 174 | { |
@@ -175,10 +177,24 @@ struct clk *clk_register_gpio_gate(struct device *dev, const char *name, | |||
175 | (parent_name ? 1 : 0), gpio, active_low, flags, | 177 | (parent_name ? 1 : 0), gpio, active_low, flags, |
176 | &clk_gpio_gate_ops); | 178 | &clk_gpio_gate_ops); |
177 | } | 179 | } |
180 | EXPORT_SYMBOL_GPL(clk_hw_register_gpio_gate); | ||
181 | |||
182 | struct clk *clk_register_gpio_gate(struct device *dev, const char *name, | ||
183 | const char *parent_name, unsigned gpio, bool active_low, | ||
184 | unsigned long flags) | ||
185 | { | ||
186 | struct clk_hw *hw; | ||
187 | |||
188 | hw = clk_hw_register_gpio_gate(dev, name, parent_name, gpio, active_low, | ||
189 | flags); | ||
190 | if (IS_ERR(hw)) | ||
191 | return ERR_CAST(hw); | ||
192 | return hw->clk; | ||
193 | } | ||
178 | EXPORT_SYMBOL_GPL(clk_register_gpio_gate); | 194 | EXPORT_SYMBOL_GPL(clk_register_gpio_gate); |
179 | 195 | ||
180 | /** | 196 | /** |
181 | * clk_register_gpio_mux - register a gpio clock mux with the clock framework | 197 | * clk_hw_register_gpio_mux - register a gpio clock mux with the clock framework |
182 | * @dev: device that is registering this clock | 198 | * @dev: device that is registering this clock |
183 | * @name: name of this clock | 199 | * @name: name of this clock |
184 | * @parent_names: names of this clock's parents | 200 | * @parent_names: names of this clock's parents |
@@ -187,7 +203,7 @@ EXPORT_SYMBOL_GPL(clk_register_gpio_gate); | |||
187 | * @active_low: true if gpio should be set to 0 to enable clock | 203 | * @active_low: true if gpio should be set to 0 to enable clock |
188 | * @flags: clock flags | 204 | * @flags: clock flags |
189 | */ | 205 | */ |
190 | struct clk *clk_register_gpio_mux(struct device *dev, const char *name, | 206 | struct clk_hw *clk_hw_register_gpio_mux(struct device *dev, const char *name, |
191 | const char * const *parent_names, u8 num_parents, unsigned gpio, | 207 | const char * const *parent_names, u8 num_parents, unsigned gpio, |
192 | bool active_low, unsigned long flags) | 208 | bool active_low, unsigned long flags) |
193 | { | 209 | { |
@@ -199,6 +215,20 @@ struct clk *clk_register_gpio_mux(struct device *dev, const char *name, | |||
199 | return clk_register_gpio(dev, name, parent_names, num_parents, | 215 | return clk_register_gpio(dev, name, parent_names, num_parents, |
200 | gpio, active_low, flags, &clk_gpio_mux_ops); | 216 | gpio, active_low, flags, &clk_gpio_mux_ops); |
201 | } | 217 | } |
218 | EXPORT_SYMBOL_GPL(clk_hw_register_gpio_mux); | ||
219 | |||
220 | struct clk *clk_register_gpio_mux(struct device *dev, const char *name, | ||
221 | const char * const *parent_names, u8 num_parents, unsigned gpio, | ||
222 | bool active_low, unsigned long flags) | ||
223 | { | ||
224 | struct clk_hw *hw; | ||
225 | |||
226 | hw = clk_hw_register_gpio_mux(dev, name, parent_names, num_parents, | ||
227 | gpio, active_low, flags); | ||
228 | if (IS_ERR(hw)) | ||
229 | return ERR_CAST(hw); | ||
230 | return hw->clk; | ||
231 | } | ||
202 | EXPORT_SYMBOL_GPL(clk_register_gpio_mux); | 232 | EXPORT_SYMBOL_GPL(clk_register_gpio_mux); |
203 | 233 | ||
204 | static int gpio_clk_driver_probe(struct platform_device *pdev) | 234 | static int gpio_clk_driver_probe(struct platform_device *pdev) |