aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2016-02-07 03:20:31 -0500
committerStephen Boyd <sboyd@codeaurora.org>2016-04-19 19:56:28 -0400
commit49cb392d36397a296dcd51ec57cf83585a89a94a (patch)
tree74bca49dcadb969d45b42b8faa9948d0ea113d6e /drivers/clk
parent39b44cff4ad4af6d7abd9dd2acb288b005c26503 (diff)
clk: composite: Add hw based registration APIs
Add registration APIs in the clk composite 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-composite.c45
1 files changed, 33 insertions, 12 deletions
diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
index 1f903e1f86a2..463fadd5a68f 100644
--- a/drivers/clk/clk-composite.c
+++ b/drivers/clk/clk-composite.c
@@ -184,17 +184,18 @@ static void clk_composite_disable(struct clk_hw *hw)
184 gate_ops->disable(gate_hw); 184 gate_ops->disable(gate_hw);
185} 185}
186 186
187struct clk *clk_register_composite(struct device *dev, const char *name, 187struct clk_hw *clk_hw_register_composite(struct device *dev, const char *name,
188 const char * const *parent_names, int num_parents, 188 const char * const *parent_names, int num_parents,
189 struct clk_hw *mux_hw, const struct clk_ops *mux_ops, 189 struct clk_hw *mux_hw, const struct clk_ops *mux_ops,
190 struct clk_hw *rate_hw, const struct clk_ops *rate_ops, 190 struct clk_hw *rate_hw, const struct clk_ops *rate_ops,
191 struct clk_hw *gate_hw, const struct clk_ops *gate_ops, 191 struct clk_hw *gate_hw, const struct clk_ops *gate_ops,
192 unsigned long flags) 192 unsigned long flags)
193{ 193{
194 struct clk *clk; 194 struct clk_hw *hw;
195 struct clk_init_data init; 195 struct clk_init_data init;
196 struct clk_composite *composite; 196 struct clk_composite *composite;
197 struct clk_ops *clk_composite_ops; 197 struct clk_ops *clk_composite_ops;
198 int ret;
198 199
199 composite = kzalloc(sizeof(*composite), GFP_KERNEL); 200 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
200 if (!composite) 201 if (!composite)
@@ -204,12 +205,13 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
204 init.flags = flags | CLK_IS_BASIC; 205 init.flags = flags | CLK_IS_BASIC;
205 init.parent_names = parent_names; 206 init.parent_names = parent_names;
206 init.num_parents = num_parents; 207 init.num_parents = num_parents;
208 hw = &composite->hw;
207 209
208 clk_composite_ops = &composite->ops; 210 clk_composite_ops = &composite->ops;
209 211
210 if (mux_hw && mux_ops) { 212 if (mux_hw && mux_ops) {
211 if (!mux_ops->get_parent) { 213 if (!mux_ops->get_parent) {
212 clk = ERR_PTR(-EINVAL); 214 hw = ERR_PTR(-EINVAL);
213 goto err; 215 goto err;
214 } 216 }
215 217
@@ -224,7 +226,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
224 226
225 if (rate_hw && rate_ops) { 227 if (rate_hw && rate_ops) {
226 if (!rate_ops->recalc_rate) { 228 if (!rate_ops->recalc_rate) {
227 clk = ERR_PTR(-EINVAL); 229 hw = ERR_PTR(-EINVAL);
228 goto err; 230 goto err;
229 } 231 }
230 clk_composite_ops->recalc_rate = clk_composite_recalc_rate; 232 clk_composite_ops->recalc_rate = clk_composite_recalc_rate;
@@ -253,7 +255,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
253 if (gate_hw && gate_ops) { 255 if (gate_hw && gate_ops) {
254 if (!gate_ops->is_enabled || !gate_ops->enable || 256 if (!gate_ops->is_enabled || !gate_ops->enable ||
255 !gate_ops->disable) { 257 !gate_ops->disable) {
256 clk = ERR_PTR(-EINVAL); 258 hw = ERR_PTR(-EINVAL);
257 goto err; 259 goto err;
258 } 260 }
259 261
@@ -267,22 +269,41 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
267 init.ops = clk_composite_ops; 269 init.ops = clk_composite_ops;
268 composite->hw.init = &init; 270 composite->hw.init = &init;
269 271
270 clk = clk_register(dev, &composite->hw); 272 ret = clk_hw_register(dev, hw);
271 if (IS_ERR(clk)) 273 if (ret) {
274 hw = ERR_PTR(ret);
272 goto err; 275 goto err;
276 }
273 277
274 if (composite->mux_hw) 278 if (composite->mux_hw)
275 composite->mux_hw->clk = clk; 279 composite->mux_hw->clk = hw->clk;
276 280
277 if (composite->rate_hw) 281 if (composite->rate_hw)
278 composite->rate_hw->clk = clk; 282 composite->rate_hw->clk = hw->clk;
279 283
280 if (composite->gate_hw) 284 if (composite->gate_hw)
281 composite->gate_hw->clk = clk; 285 composite->gate_hw->clk = hw->clk;
282 286
283 return clk; 287 return hw;
284 288
285err: 289err:
286 kfree(composite); 290 kfree(composite);
287 return clk; 291 return hw;
292}
293
294struct clk *clk_register_composite(struct device *dev, const char *name,
295 const char * const *parent_names, int num_parents,
296 struct clk_hw *mux_hw, const struct clk_ops *mux_ops,
297 struct clk_hw *rate_hw, const struct clk_ops *rate_ops,
298 struct clk_hw *gate_hw, const struct clk_ops *gate_ops,
299 unsigned long flags)
300{
301 struct clk_hw *hw;
302
303 hw = clk_hw_register_composite(dev, name, parent_names, num_parents,
304 mux_hw, mux_ops, rate_hw, rate_ops, gate_hw, gate_ops,
305 flags);
306 if (IS_ERR(hw))
307 return ERR_CAST(hw);
308 return hw->clk;
288} 309}