summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2016-02-07 03:34:13 -0500
committerStephen Boyd <sboyd@codeaurora.org>2016-04-19 19:57:12 -0400
commit26ef56be9e0944a9b136169eb47140f309ce745b (patch)
tree5aa58657113ea14939e9fa95c4f571a847ff3f66
parentb120743a64a3ec68b8c5310a6009094329b4a33b (diff)
clk: fixed-rate: Add hw based registration APIs
Add registration APIs in the clk fixed-rate 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>
-rw-r--r--drivers/clk/clk-fixed-rate.c44
-rw-r--r--include/linux/clk-provider.h7
2 files changed, 43 insertions, 8 deletions
diff --git a/drivers/clk/clk-fixed-rate.c b/drivers/clk/clk-fixed-rate.c
index cd9dc925b3f8..8e4453eb54e8 100644
--- a/drivers/clk/clk-fixed-rate.c
+++ b/drivers/clk/clk-fixed-rate.c
@@ -45,8 +45,8 @@ const struct clk_ops clk_fixed_rate_ops = {
45EXPORT_SYMBOL_GPL(clk_fixed_rate_ops); 45EXPORT_SYMBOL_GPL(clk_fixed_rate_ops);
46 46
47/** 47/**
48 * clk_register_fixed_rate_with_accuracy - register fixed-rate clock with the 48 * clk_hw_register_fixed_rate_with_accuracy - register fixed-rate clock with
49 * clock framework 49 * the clock framework
50 * @dev: device that is registering this clock 50 * @dev: device that is registering this clock
51 * @name: name of this clock 51 * @name: name of this clock
52 * @parent_name: name of clock's parent 52 * @parent_name: name of clock's parent
@@ -54,13 +54,14 @@ EXPORT_SYMBOL_GPL(clk_fixed_rate_ops);
54 * @fixed_rate: non-adjustable clock rate 54 * @fixed_rate: non-adjustable clock rate
55 * @fixed_accuracy: non-adjustable clock rate 55 * @fixed_accuracy: non-adjustable clock rate
56 */ 56 */
57struct clk *clk_register_fixed_rate_with_accuracy(struct device *dev, 57struct clk_hw *clk_hw_register_fixed_rate_with_accuracy(struct device *dev,
58 const char *name, const char *parent_name, unsigned long flags, 58 const char *name, const char *parent_name, unsigned long flags,
59 unsigned long fixed_rate, unsigned long fixed_accuracy) 59 unsigned long fixed_rate, unsigned long fixed_accuracy)
60{ 60{
61 struct clk_fixed_rate *fixed; 61 struct clk_fixed_rate *fixed;
62 struct clk *clk; 62 struct clk_hw *hw;
63 struct clk_init_data init; 63 struct clk_init_data init;
64 int ret;
64 65
65 /* allocate fixed-rate clock */ 66 /* allocate fixed-rate clock */
66 fixed = kzalloc(sizeof(*fixed), GFP_KERNEL); 67 fixed = kzalloc(sizeof(*fixed), GFP_KERNEL);
@@ -79,22 +80,49 @@ struct clk *clk_register_fixed_rate_with_accuracy(struct device *dev,
79 fixed->hw.init = &init; 80 fixed->hw.init = &init;
80 81
81 /* register the clock */ 82 /* register the clock */
82 clk = clk_register(dev, &fixed->hw); 83 hw = &fixed->hw;
83 if (IS_ERR(clk)) 84 ret = clk_hw_register(dev, hw);
85 if (ret) {
84 kfree(fixed); 86 kfree(fixed);
87 hw = ERR_PTR(ret);
88 }
85 89
86 return clk; 90 return hw;
91}
92EXPORT_SYMBOL_GPL(clk_hw_register_fixed_rate_with_accuracy);
93
94struct clk *clk_register_fixed_rate_with_accuracy(struct device *dev,
95 const char *name, const char *parent_name, unsigned long flags,
96 unsigned long fixed_rate, unsigned long fixed_accuracy)
97{
98 struct clk_hw *hw;
99
100 hw = clk_hw_register_fixed_rate_with_accuracy(dev, name, parent_name,
101 flags, fixed_rate, fixed_accuracy);
102 if (IS_ERR(hw))
103 return ERR_CAST(hw);
104 return hw->clk;
87} 105}
88EXPORT_SYMBOL_GPL(clk_register_fixed_rate_with_accuracy); 106EXPORT_SYMBOL_GPL(clk_register_fixed_rate_with_accuracy);
89 107
90/** 108/**
91 * clk_register_fixed_rate - register fixed-rate clock with the clock framework 109 * clk_hw_register_fixed_rate - register fixed-rate clock with the clock
110 * framework
92 * @dev: device that is registering this clock 111 * @dev: device that is registering this clock
93 * @name: name of this clock 112 * @name: name of this clock
94 * @parent_name: name of clock's parent 113 * @parent_name: name of clock's parent
95 * @flags: framework-specific flags 114 * @flags: framework-specific flags
96 * @fixed_rate: non-adjustable clock rate 115 * @fixed_rate: non-adjustable clock rate
97 */ 116 */
117struct clk_hw *clk_hw_register_fixed_rate(struct device *dev, const char *name,
118 const char *parent_name, unsigned long flags,
119 unsigned long fixed_rate)
120{
121 return clk_hw_register_fixed_rate_with_accuracy(dev, name, parent_name,
122 flags, fixed_rate, 0);
123}
124EXPORT_SYMBOL_GPL(clk_hw_register_fixed_rate);
125
98struct clk *clk_register_fixed_rate(struct device *dev, const char *name, 126struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
99 const char *parent_name, unsigned long flags, 127 const char *parent_name, unsigned long flags,
100 unsigned long fixed_rate) 128 unsigned long fixed_rate)
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 6c36c5e8ccbe..c3fc042d517c 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -282,10 +282,17 @@ extern const struct clk_ops clk_fixed_rate_ops;
282struct clk *clk_register_fixed_rate(struct device *dev, const char *name, 282struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
283 const char *parent_name, unsigned long flags, 283 const char *parent_name, unsigned long flags,
284 unsigned long fixed_rate); 284 unsigned long fixed_rate);
285struct clk_hw *clk_hw_register_fixed_rate(struct device *dev, const char *name,
286 const char *parent_name, unsigned long flags,
287 unsigned long fixed_rate);
285struct clk *clk_register_fixed_rate_with_accuracy(struct device *dev, 288struct clk *clk_register_fixed_rate_with_accuracy(struct device *dev,
286 const char *name, const char *parent_name, unsigned long flags, 289 const char *name, const char *parent_name, unsigned long flags,
287 unsigned long fixed_rate, unsigned long fixed_accuracy); 290 unsigned long fixed_rate, unsigned long fixed_accuracy);
288void clk_unregister_fixed_rate(struct clk *clk); 291void clk_unregister_fixed_rate(struct clk *clk);
292struct clk_hw *clk_hw_register_fixed_rate_with_accuracy(struct device *dev,
293 const char *name, const char *parent_name, unsigned long flags,
294 unsigned long fixed_rate, unsigned long fixed_accuracy);
295
289void of_fixed_clk_setup(struct device_node *np); 296void of_fixed_clk_setup(struct device_node *np);
290 297
291/** 298/**