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

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>

authored by

Stephen Boyd and committed by
Stephen Boyd
93ae00be a8b6e85d

+14 -19
+14 -19
drivers/clk/clk-scpi.c
··· 146 146 {} 147 147 }; 148 148 149 - static struct clk * 149 + static int 150 150 scpi_clk_ops_init(struct device *dev, const struct of_device_id *match, 151 151 struct scpi_clk *sclk, const char *name) 152 152 { 153 153 struct clk_init_data init; 154 - struct clk *clk; 155 154 unsigned long min = 0, max = 0; 155 + int ret; 156 156 157 157 init.name = name; 158 158 init.flags = 0; ··· 164 164 if (init.ops == &scpi_dvfs_ops) { 165 165 sclk->info = sclk->scpi_ops->dvfs_get_info(sclk->id); 166 166 if (IS_ERR(sclk->info)) 167 - return NULL; 167 + return PTR_ERR(sclk->info); 168 168 } else if (init.ops == &scpi_clk_ops) { 169 169 if (sclk->scpi_ops->clk_get_range(sclk->id, &min, &max) || !max) 170 - return NULL; 170 + return -EINVAL; 171 171 } else { 172 - return NULL; 172 + return -EINVAL; 173 173 } 174 174 175 - clk = devm_clk_register(dev, &sclk->hw); 176 - if (!IS_ERR(clk) && max) 175 + ret = devm_clk_hw_register(dev, &sclk->hw); 176 + if (!ret && max) 177 177 clk_hw_set_rate_range(&sclk->hw, min, max); 178 - return clk; 178 + return ret; 179 179 } 180 180 181 181 struct scpi_clk_data { ··· 183 183 unsigned int clk_num; 184 184 }; 185 185 186 - static struct clk * 186 + static struct clk_hw * 187 187 scpi_of_clk_src_get(struct of_phandle_args *clkspec, void *data) 188 188 { 189 189 struct scpi_clk *sclk; ··· 193 193 for (count = 0; count < clk_data->clk_num; count++) { 194 194 sclk = clk_data->clk[count]; 195 195 if (idx == sclk->id) 196 - return sclk->hw.clk; 196 + return &sclk->hw; 197 197 } 198 198 199 199 return ERR_PTR(-EINVAL); ··· 202 202 static int scpi_clk_add(struct device *dev, struct device_node *np, 203 203 const struct of_device_id *match) 204 204 { 205 - struct clk **clks; 206 - int idx, count; 205 + int idx, count, err; 207 206 struct scpi_clk_data *clk_data; 208 207 209 208 count = of_property_count_strings(np, "clock-output-names"); ··· 219 220 clk_data->clk = devm_kcalloc(dev, count, sizeof(*clk_data->clk), 220 221 GFP_KERNEL); 221 222 if (!clk_data->clk) 222 - return -ENOMEM; 223 - 224 - clks = devm_kcalloc(dev, count, sizeof(*clks), GFP_KERNEL); 225 - if (!clks) 226 223 return -ENOMEM; 227 224 228 225 for (idx = 0; idx < count; idx++) { ··· 244 249 245 250 sclk->id = val; 246 251 247 - clks[idx] = scpi_clk_ops_init(dev, match, sclk, name); 248 - if (IS_ERR_OR_NULL(clks[idx])) 252 + err = scpi_clk_ops_init(dev, match, sclk, name); 253 + if (err) 249 254 dev_err(dev, "failed to register clock '%s'\n", name); 250 255 else 251 256 dev_dbg(dev, "Registered clock '%s'\n", name); 252 257 clk_data->clk[idx] = sclk; 253 258 } 254 259 255 - return of_clk_add_provider(np, scpi_of_clk_src_get, clk_data); 260 + return of_clk_add_hw_provider(np, scpi_of_clk_src_get, clk_data); 256 261 } 257 262 258 263 static int scpi_clocks_remove(struct platform_device *pdev)