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

clk: ti: change ti_clk_register[_omap_hw]() API

The ti_clk_register() and ti_clk_register_omap_hw() functions are always
called with the parameter of type "struct device" set to NULL, since the
functions from which they are called always have a parameter of type
"struct device_node". Replacing "struct device" type parameter with
"struct device_node" will allow you to register a TI clock to the common
clock framework by taking advantage of the facilities provided by the
"struct device_node" type. Further, adding the "of_" prefix to the name
of these functions explicitly binds them to the "struct device_node"
type.

The patch has been tested on a Beaglebone board.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Tony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20221113181147.1626585-1-dario.binacchi@amarulasolutions.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Dario Binacchi and committed by
Stephen Boyd
3400d546 9abf2313

+41 -42
+2 -2
drivers/clk/ti/apll.c
··· 160 160 ad->clk_bypass = __clk_get_hw(clk); 161 161 162 162 name = ti_dt_clk_name(node); 163 - clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name); 163 + clk = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name); 164 164 if (!IS_ERR(clk)) { 165 165 of_clk_add_provider(node, of_clk_src_simple_get, clk); 166 166 kfree(init->parent_names); ··· 400 400 goto cleanup; 401 401 402 402 name = ti_dt_clk_name(node); 403 - clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name); 403 + clk = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name); 404 404 if (!IS_ERR(clk)) { 405 405 of_clk_add_provider(node, of_clk_src_simple_get, clk); 406 406 kfree(init);
+1 -1
drivers/clk/ti/clk-dra7-atl.c
··· 197 197 198 198 init.parent_names = parent_names; 199 199 200 - clk = ti_clk_register(NULL, &clk_hw->hw, name); 200 + clk = of_ti_clk_register(node, &clk_hw->hw, name); 201 201 202 202 if (!IS_ERR(clk)) { 203 203 of_clk_add_provider(node, of_clk_src_simple_get, clk);
+16 -18
drivers/clk/ti/clk.c
··· 475 475 clkspec.np = np; 476 476 clk = of_clk_get_from_provider(&clkspec); 477 477 478 - ti_clk_add_alias(NULL, clk, ti_dt_clk_name(np)); 478 + ti_clk_add_alias(clk, ti_dt_clk_name(np)); 479 479 } 480 480 } 481 481 ··· 528 528 529 529 /** 530 530 * ti_clk_add_alias - add a clock alias for a TI clock 531 - * @dev: device alias for this clock 532 531 * @clk: clock handle to create alias for 533 532 * @con: connection ID for this clock 534 533 * ··· 535 536 * and assigns the data to it. Returns 0 if successful, negative error 536 537 * value otherwise. 537 538 */ 538 - int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con) 539 + int ti_clk_add_alias(struct clk *clk, const char *con) 539 540 { 540 541 struct clk_lookup *cl; 541 542 ··· 549 550 if (!cl) 550 551 return -ENOMEM; 551 552 552 - if (dev) 553 - cl->dev_id = dev_name(dev); 554 553 cl->con_id = con; 555 554 cl->clk = clk; 556 555 ··· 558 561 } 559 562 560 563 /** 561 - * ti_clk_register - register a TI clock to the common clock framework 562 - * @dev: device for this clock 564 + * of_ti_clk_register - register a TI clock to the common clock framework 565 + * @node: device node for this clock 563 566 * @hw: hardware clock handle 564 567 * @con: connection ID for this clock 565 568 * ··· 567 570 * alias for it. Returns a handle to the registered clock if successful, 568 571 * ERR_PTR value in failure. 569 572 */ 570 - struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw, 571 - const char *con) 573 + struct clk *of_ti_clk_register(struct device_node *node, struct clk_hw *hw, 574 + const char *con) 572 575 { 573 576 struct clk *clk; 574 577 int ret; 575 578 576 - clk = clk_register(dev, hw); 577 - if (IS_ERR(clk)) 578 - return clk; 579 + ret = of_clk_hw_register(node, hw); 580 + if (ret) 581 + return ERR_PTR(ret); 579 582 580 - ret = ti_clk_add_alias(dev, clk, con); 583 + clk = hw->clk; 584 + ret = ti_clk_add_alias(clk, con); 581 585 if (ret) { 582 586 clk_unregister(clk); 583 587 return ERR_PTR(ret); ··· 588 590 } 589 591 590 592 /** 591 - * ti_clk_register_omap_hw - register a clk_hw_omap to the clock framework 592 - * @dev: device for this clock 593 + * of_ti_clk_register_omap_hw - register a clk_hw_omap to the clock framework 594 + * @node: device node for this clock 593 595 * @hw: hardware clock handle 594 596 * @con: connection ID for this clock 595 597 * ··· 598 600 * Returns a handle to the registered clock if successful, ERR_PTR value 599 601 * in failure. 600 602 */ 601 - struct clk *ti_clk_register_omap_hw(struct device *dev, struct clk_hw *hw, 602 - const char *con) 603 + struct clk *of_ti_clk_register_omap_hw(struct device_node *node, 604 + struct clk_hw *hw, const char *con) 603 605 { 604 606 struct clk *clk; 605 607 struct clk_hw_omap *oclk; 606 608 607 - clk = ti_clk_register(dev, hw, con); 609 + clk = of_ti_clk_register(node, hw, con); 608 610 if (IS_ERR(clk)) 609 611 return clk; 610 612
+2 -2
drivers/clk/ti/clkctrl.c
··· 305 305 init.ops = ops; 306 306 init.flags = 0; 307 307 308 - clk = ti_clk_register(NULL, clk_hw, init.name); 308 + clk = of_ti_clk_register(node, clk_hw, init.name); 309 309 if (IS_ERR_OR_NULL(clk)) { 310 310 ret = -EINVAL; 311 311 goto cleanup; ··· 682 682 init.ops = &omap4_clkctrl_clk_ops; 683 683 hw->hw.init = &init; 684 684 685 - clk = ti_clk_register_omap_hw(NULL, &hw->hw, init.name); 685 + clk = of_ti_clk_register_omap_hw(node, &hw->hw, init.name); 686 686 if (IS_ERR_OR_NULL(clk)) 687 687 goto cleanup; 688 688
+5 -5
drivers/clk/ti/clock.h
··· 199 199 200 200 typedef void (*ti_of_clk_init_cb_t)(void *, struct device_node *); 201 201 202 - struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw, 203 - const char *con); 204 - struct clk *ti_clk_register_omap_hw(struct device *dev, struct clk_hw *hw, 205 - const char *con); 202 + struct clk *of_ti_clk_register(struct device_node *node, struct clk_hw *hw, 203 + const char *con); 204 + struct clk *of_ti_clk_register_omap_hw(struct device_node *node, 205 + struct clk_hw *hw, const char *con); 206 206 const char *ti_dt_clk_name(struct device_node *np); 207 - int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con); 207 + int ti_clk_add_alias(struct clk *clk, const char *con); 208 208 void ti_clk_add_aliases(void); 209 209 210 210 void ti_clk_latch(struct clk_omap_reg *reg, s8 shift);
+1 -1
drivers/clk/ti/composite.c
··· 176 176 &ti_composite_gate_ops, 0); 177 177 178 178 if (!IS_ERR(clk)) { 179 - ret = ti_clk_add_alias(NULL, clk, name); 179 + ret = ti_clk_add_alias(clk, name); 180 180 if (ret) { 181 181 clk_unregister(clk); 182 182 goto cleanup;
+1 -1
drivers/clk/ti/divider.c
··· 326 326 div->hw.init = &init; 327 327 328 328 /* register the clock */ 329 - clk = ti_clk_register(NULL, &div->hw, name); 329 + clk = of_ti_clk_register(node, &div->hw, name); 330 330 331 331 if (IS_ERR(clk)) 332 332 kfree(div);
+2 -2
drivers/clk/ti/dpll.c
··· 187 187 188 188 /* register the clock */ 189 189 name = ti_dt_clk_name(node); 190 - clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name); 190 + clk = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name); 191 191 192 192 if (!IS_ERR(clk)) { 193 193 of_clk_add_provider(node, of_clk_src_simple_get, clk); ··· 259 259 #endif 260 260 261 261 /* register the clock */ 262 - clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name); 262 + clk = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name); 263 263 264 264 if (IS_ERR(clk)) 265 265 kfree(clk_hw);
+1 -1
drivers/clk/ti/fixed-factor.c
··· 54 54 if (!IS_ERR(clk)) { 55 55 of_clk_add_provider(node, of_clk_src_simple_get, clk); 56 56 of_ti_clk_autoidle_setup(node); 57 - ti_clk_add_alias(NULL, clk, clk_name); 57 + ti_clk_add_alias(clk, clk_name); 58 58 } 59 59 } 60 60 CLK_OF_DECLARE(ti_fixed_factor_clk, "ti,fixed-factor-clock",
+3 -3
drivers/clk/ti/gate.c
··· 85 85 return ret; 86 86 } 87 87 88 - static struct clk *_register_gate(struct device *dev, const char *name, 88 + static struct clk *_register_gate(struct device_node *node, const char *name, 89 89 const char *parent_name, unsigned long flags, 90 90 struct clk_omap_reg *reg, u8 bit_idx, 91 91 u8 clk_gate_flags, const struct clk_ops *ops, ··· 115 115 116 116 init.flags = flags; 117 117 118 - clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name); 118 + clk = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name); 119 119 120 120 if (IS_ERR(clk)) 121 121 kfree(clk_hw); ··· 158 158 clk_gate_flags |= INVERT_ENABLE; 159 159 160 160 name = ti_dt_clk_name(node); 161 - clk = _register_gate(NULL, name, parent_name, flags, &reg, 161 + clk = _register_gate(node, name, parent_name, flags, &reg, 162 162 enable_bit, clk_gate_flags, ops, hw_ops); 163 163 164 164 if (!IS_ERR(clk))
+4 -3
drivers/clk/ti/interface.c
··· 24 24 .is_enabled = &omap2_dflt_clk_is_enabled, 25 25 }; 26 26 27 - static struct clk *_register_interface(struct device *dev, const char *name, 27 + static struct clk *_register_interface(struct device_node *node, 28 + const char *name, 28 29 const char *parent_name, 29 30 struct clk_omap_reg *reg, u8 bit_idx, 30 31 const struct clk_hw_omap_ops *ops) ··· 50 49 init.num_parents = 1; 51 50 init.parent_names = &parent_name; 52 51 53 - clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name); 52 + clk = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name); 54 53 55 54 if (IS_ERR(clk)) 56 55 kfree(clk_hw); ··· 81 80 } 82 81 83 82 name = ti_dt_clk_name(node); 84 - clk = _register_interface(NULL, name, parent_name, &reg, 83 + clk = _register_interface(node, name, parent_name, &reg, 85 84 enable_bit, ops); 86 85 87 86 if (!IS_ERR(clk))
+3 -3
drivers/clk/ti/mux.c
··· 118 118 .restore_context = clk_mux_restore_context, 119 119 }; 120 120 121 - static struct clk *_register_mux(struct device *dev, const char *name, 121 + static struct clk *_register_mux(struct device_node *node, const char *name, 122 122 const char * const *parent_names, 123 123 u8 num_parents, unsigned long flags, 124 124 struct clk_omap_reg *reg, u8 shift, u32 mask, ··· 148 148 mux->table = table; 149 149 mux->hw.init = &init; 150 150 151 - clk = ti_clk_register(dev, &mux->hw, name); 151 + clk = of_ti_clk_register(node, &mux->hw, name); 152 152 153 153 if (IS_ERR(clk)) 154 154 kfree(mux); ··· 207 207 mask = (1 << fls(mask)) - 1; 208 208 209 209 name = ti_dt_clk_name(node); 210 - clk = _register_mux(NULL, name, parent_names, num_parents, 210 + clk = _register_mux(node, name, parent_names, num_parents, 211 211 flags, &reg, shift, mask, latch, clk_mux_flags, 212 212 NULL); 213 213