aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Boyd <stephen.boyd@linaro.org>2016-06-01 19:15:25 -0400
committerStephen Boyd <sboyd@codeaurora.org>2016-08-24 20:29:58 -0400
commit93ae00be20d872bfa3099e6376442362aaa8d567 (patch)
tree6ec263ea20228c20a2ce1277777fc865504c1250
parenta8b6e85db6a65132ebc85e38b6391669b37b36f8 (diff)
clk: scpi: Migrate to clk_hw based OF and registration APIs
Now that we have clk_hw based provider APIs to register clks, we can get rid of struct clk pointers while registering clks in these drivers, allowing us to move closer to a clear split of consumer and provider clk APIs. Cc: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
-rw-r--r--drivers/clk/clk-scpi.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/drivers/clk/clk-scpi.c b/drivers/clk/clk-scpi.c
index 6962ee5d1e9a..2a3e9d8e88b0 100644
--- a/drivers/clk/clk-scpi.c
+++ b/drivers/clk/clk-scpi.c
@@ -146,13 +146,13 @@ static const struct of_device_id scpi_clk_match[] = {
146 {} 146 {}
147}; 147};
148 148
149static struct clk * 149static int
150scpi_clk_ops_init(struct device *dev, const struct of_device_id *match, 150scpi_clk_ops_init(struct device *dev, const struct of_device_id *match,
151 struct scpi_clk *sclk, const char *name) 151 struct scpi_clk *sclk, const char *name)
152{ 152{
153 struct clk_init_data init; 153 struct clk_init_data init;
154 struct clk *clk;
155 unsigned long min = 0, max = 0; 154 unsigned long min = 0, max = 0;
155 int ret;
156 156
157 init.name = name; 157 init.name = name;
158 init.flags = 0; 158 init.flags = 0;
@@ -164,18 +164,18 @@ scpi_clk_ops_init(struct device *dev, const struct of_device_id *match,
164 if (init.ops == &scpi_dvfs_ops) { 164 if (init.ops == &scpi_dvfs_ops) {
165 sclk->info = sclk->scpi_ops->dvfs_get_info(sclk->id); 165 sclk->info = sclk->scpi_ops->dvfs_get_info(sclk->id);
166 if (IS_ERR(sclk->info)) 166 if (IS_ERR(sclk->info))
167 return NULL; 167 return PTR_ERR(sclk->info);
168 } else if (init.ops == &scpi_clk_ops) { 168 } else if (init.ops == &scpi_clk_ops) {
169 if (sclk->scpi_ops->clk_get_range(sclk->id, &min, &max) || !max) 169 if (sclk->scpi_ops->clk_get_range(sclk->id, &min, &max) || !max)
170 return NULL; 170 return -EINVAL;
171 } else { 171 } else {
172 return NULL; 172 return -EINVAL;
173 } 173 }
174 174
175 clk = devm_clk_register(dev, &sclk->hw); 175 ret = devm_clk_hw_register(dev, &sclk->hw);
176 if (!IS_ERR(clk) && max) 176 if (!ret && max)
177 clk_hw_set_rate_range(&sclk->hw, min, max); 177 clk_hw_set_rate_range(&sclk->hw, min, max);
178 return clk; 178 return ret;
179} 179}
180 180
181struct scpi_clk_data { 181struct scpi_clk_data {
@@ -183,7 +183,7 @@ struct scpi_clk_data {
183 unsigned int clk_num; 183 unsigned int clk_num;
184}; 184};
185 185
186static struct clk * 186static struct clk_hw *
187scpi_of_clk_src_get(struct of_phandle_args *clkspec, void *data) 187scpi_of_clk_src_get(struct of_phandle_args *clkspec, void *data)
188{ 188{
189 struct scpi_clk *sclk; 189 struct scpi_clk *sclk;
@@ -193,7 +193,7 @@ scpi_of_clk_src_get(struct of_phandle_args *clkspec, void *data)
193 for (count = 0; count < clk_data->clk_num; count++) { 193 for (count = 0; count < clk_data->clk_num; count++) {
194 sclk = clk_data->clk[count]; 194 sclk = clk_data->clk[count];
195 if (idx == sclk->id) 195 if (idx == sclk->id)
196 return sclk->hw.clk; 196 return &sclk->hw;
197 } 197 }
198 198
199 return ERR_PTR(-EINVAL); 199 return ERR_PTR(-EINVAL);
@@ -202,8 +202,7 @@ scpi_of_clk_src_get(struct of_phandle_args *clkspec, void *data)
202static int scpi_clk_add(struct device *dev, struct device_node *np, 202static int scpi_clk_add(struct device *dev, struct device_node *np,
203 const struct of_device_id *match) 203 const struct of_device_id *match)
204{ 204{
205 struct clk **clks; 205 int idx, count, err;
206 int idx, count;
207 struct scpi_clk_data *clk_data; 206 struct scpi_clk_data *clk_data;
208 207
209 count = of_property_count_strings(np, "clock-output-names"); 208 count = of_property_count_strings(np, "clock-output-names");
@@ -222,10 +221,6 @@ static int scpi_clk_add(struct device *dev, struct device_node *np,
222 if (!clk_data->clk) 221 if (!clk_data->clk)
223 return -ENOMEM; 222 return -ENOMEM;
224 223
225 clks = devm_kcalloc(dev, count, sizeof(*clks), GFP_KERNEL);
226 if (!clks)
227 return -ENOMEM;
228
229 for (idx = 0; idx < count; idx++) { 224 for (idx = 0; idx < count; idx++) {
230 struct scpi_clk *sclk; 225 struct scpi_clk *sclk;
231 const char *name; 226 const char *name;
@@ -249,15 +244,15 @@ static int scpi_clk_add(struct device *dev, struct device_node *np,
249 244
250 sclk->id = val; 245 sclk->id = val;
251 246
252 clks[idx] = scpi_clk_ops_init(dev, match, sclk, name); 247 err = scpi_clk_ops_init(dev, match, sclk, name);
253 if (IS_ERR_OR_NULL(clks[idx])) 248 if (err)
254 dev_err(dev, "failed to register clock '%s'\n", name); 249 dev_err(dev, "failed to register clock '%s'\n", name);
255 else 250 else
256 dev_dbg(dev, "Registered clock '%s'\n", name); 251 dev_dbg(dev, "Registered clock '%s'\n", name);
257 clk_data->clk[idx] = sclk; 252 clk_data->clk[idx] = sclk;
258 } 253 }
259 254
260 return of_clk_add_provider(np, scpi_of_clk_src_get, clk_data); 255 return of_clk_add_hw_provider(np, scpi_of_clk_src_get, clk_data);
261} 256}
262 257
263static int scpi_clocks_remove(struct platform_device *pdev) 258static int scpi_clocks_remove(struct platform_device *pdev)