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

clk: asm9260: Migrate to clk_hw based registration and OF 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: Oleksij Rempel <linux@rempel-privat.de>
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
78cf5555 f37fccce

+18 -13
+18 -13
drivers/clk/clk-asm9260.c
··· 68 68 #define HW_LCDCLKDIV 0x01fc 69 69 #define HW_ADCANACLKDIV 0x0200 70 70 71 - static struct clk *clks[MAX_CLKS]; 72 - static struct clk_onecell_data clk_data; 71 + static struct clk_hw_onecell_data *clk_data; 73 72 static DEFINE_SPINLOCK(asm9260_clk_lock); 74 73 75 74 struct asm9260_div_clk { ··· 266 267 267 268 static void __init asm9260_acc_init(struct device_node *np) 268 269 { 269 - struct clk *clk; 270 + struct clk_hw *hw; 271 + struct clk_hw **hws; 270 272 const char *ref_clk, *pll_clk = "pll"; 271 273 u32 rate; 272 274 int n; 273 275 u32 accuracy = 0; 276 + 277 + clk_data = kzalloc(sizeof(*clk_data) + 278 + sizeof(*clk_data->hws) * MAX_CLKS, GFP_KERNEL); 279 + if (!clk_data) 280 + return; 281 + clk_data->num = MAX_CLKS; 282 + hws = clk_data->hws; 274 283 275 284 base = of_io_request_and_map(np, 0, np->name); 276 285 if (IS_ERR(base)) ··· 289 282 290 283 ref_clk = of_clk_get_parent_name(np, 0); 291 284 accuracy = clk_get_accuracy(__clk_lookup(ref_clk)); 292 - clk = clk_register_fixed_rate_with_accuracy(NULL, pll_clk, 285 + hw = clk_hw_register_fixed_rate_with_accuracy(NULL, pll_clk, 293 286 ref_clk, 0, rate, accuracy); 294 287 295 - if (IS_ERR(clk)) 288 + if (IS_ERR(hw)) 296 289 panic("%s: can't register REFCLK. Check DT!", np->name); 297 290 298 291 for (n = 0; n < ARRAY_SIZE(asm9260_mux_clks); n++) { ··· 300 293 301 294 mc->parent_names[0] = ref_clk; 302 295 mc->parent_names[1] = pll_clk; 303 - clk = clk_register_mux_table(NULL, mc->name, mc->parent_names, 296 + hw = clk_hw_register_mux_table(NULL, mc->name, mc->parent_names, 304 297 mc->num_parents, mc->flags, base + mc->offset, 305 298 0, mc->mask, 0, mc->table, &asm9260_clk_lock); 306 299 } ··· 309 302 for (n = 0; n < ARRAY_SIZE(asm9260_mux_gates); n++) { 310 303 const struct asm9260_gate_data *gd = &asm9260_mux_gates[n]; 311 304 312 - clk = clk_register_gate(NULL, gd->name, 305 + hw = clk_hw_register_gate(NULL, gd->name, 313 306 gd->parent_name, gd->flags | CLK_SET_RATE_PARENT, 314 307 base + gd->reg, gd->bit_idx, 0, &asm9260_clk_lock); 315 308 } ··· 318 311 for (n = 0; n < ARRAY_SIZE(asm9260_div_clks); n++) { 319 312 const struct asm9260_div_clk *dc = &asm9260_div_clks[n]; 320 313 321 - clks[dc->idx] = clk_register_divider(NULL, dc->name, 314 + hws[dc->idx] = clk_hw_register_divider(NULL, dc->name, 322 315 dc->parent_name, CLK_SET_RATE_PARENT, 323 316 base + dc->reg, 0, 8, CLK_DIVIDER_ONE_BASED, 324 317 &asm9260_clk_lock); ··· 328 321 for (n = 0; n < ARRAY_SIZE(asm9260_ahb_gates); n++) { 329 322 const struct asm9260_gate_data *gd = &asm9260_ahb_gates[n]; 330 323 331 - clks[gd->idx] = clk_register_gate(NULL, gd->name, 324 + hws[gd->idx] = clk_hw_register_gate(NULL, gd->name, 332 325 gd->parent_name, gd->flags, base + gd->reg, 333 326 gd->bit_idx, 0, &asm9260_clk_lock); 334 327 } 335 328 336 329 /* check for errors on leaf clocks */ 337 330 for (n = 0; n < MAX_CLKS; n++) { 338 - if (!IS_ERR(clks[n])) 331 + if (!IS_ERR(hws[n])) 339 332 continue; 340 333 341 334 pr_err("%s: Unable to register leaf clock %d\n", ··· 344 337 } 345 338 346 339 /* register clk-provider */ 347 - clk_data.clks = clks; 348 - clk_data.clk_num = MAX_CLKS; 349 - of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); 340 + of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_data); 350 341 return; 351 342 fail: 352 343 iounmap(base);