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

clk: cdce: 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: Max Filippov <jcmvbkbc@gmail.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
01b5200a 235d2aaa

+22 -18
+22 -18
drivers/clk/clk-cdce706.c
··· 71 71 struct cdce706_dev_data *dev_data; 72 72 unsigned idx; 73 73 unsigned parent; 74 - struct clk *clk; 75 74 struct clk_hw hw; 76 75 unsigned div; 77 76 unsigned mul; ··· 80 81 struct cdce706_dev_data { 81 82 struct i2c_client *client; 82 83 struct regmap *regmap; 83 - struct clk_onecell_data onecell; 84 - struct clk *clks[6]; 85 84 struct clk *clkin_clk[2]; 86 85 const char *clkin_name[2]; 87 86 struct cdce706_hw_data clkin[1]; ··· 452 455 struct clk_init_data *init) 453 456 { 454 457 unsigned i; 458 + int ret; 455 459 456 460 for (i = 0; i < num_hw; ++i, ++hw) { 457 461 init->name = clk_names[i]; 458 462 hw->dev_data = cdce; 459 463 hw->idx = i; 460 464 hw->hw.init = init; 461 - hw->clk = devm_clk_register(&cdce->client->dev, 465 + ret = devm_clk_hw_register(&cdce->client->dev, 462 466 &hw->hw); 463 - if (IS_ERR(hw->clk)) { 467 + if (ret) { 464 468 dev_err(&cdce->client->dev, "Failed to register %s\n", 465 469 clk_names[i]); 466 - return PTR_ERR(hw->clk); 470 + return ret; 467 471 } 468 472 } 469 473 return 0; ··· 611 613 cdce->clkout[i].parent); 612 614 } 613 615 614 - ret = cdce706_register_hw(cdce, cdce->clkout, 615 - ARRAY_SIZE(cdce->clkout), 616 - cdce706_clkout_name, &init); 617 - for (i = 0; i < ARRAY_SIZE(cdce->clkout); ++i) 618 - cdce->clks[i] = cdce->clkout[i].clk; 616 + return cdce706_register_hw(cdce, cdce->clkout, 617 + ARRAY_SIZE(cdce->clkout), 618 + cdce706_clkout_name, &init); 619 + } 619 620 620 - return ret; 621 + static struct clk_hw * 622 + of_clk_cdce_get(struct of_phandle_args *clkspec, void *data) 623 + { 624 + struct cdce706_dev_data *cdce = data; 625 + unsigned int idx = clkspec->args[0]; 626 + 627 + if (idx >= ARRAY_SIZE(cdce->clkout)) { 628 + pr_err("%s: invalid index %u\n", __func__, idx); 629 + return ERR_PTR(-EINVAL); 630 + } 631 + 632 + return &cdce->clkout[idx].hw; 621 633 } 622 634 623 635 static int cdce706_probe(struct i2c_client *client, ··· 665 657 ret = cdce706_register_clkouts(cdce); 666 658 if (ret < 0) 667 659 return ret; 668 - cdce->onecell.clks = cdce->clks; 669 - cdce->onecell.clk_num = ARRAY_SIZE(cdce->clks); 670 - ret = of_clk_add_provider(client->dev.of_node, of_clk_src_onecell_get, 671 - &cdce->onecell); 672 - 673 - return ret; 660 + return of_clk_add_hw_provider(client->dev.of_node, of_clk_cdce_get, 661 + cdce); 674 662 } 675 663 676 664 static int cdce706_remove(struct i2c_client *client)