Commit 9b4cac33 authored by Stephen Boyd's avatar Stephen Boyd Committed by Stephen Boyd

clk: max77686: 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.
Reviewed-by: default avatarJavier Martinez Canillas <javier@osg.samsung.com>
Tested-by: default avatarJavier Martinez Canillas <javier@osg.samsung.com>
Cc: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: default avatarKrzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: default avatarStephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
parent 91d17dc3
...@@ -62,9 +62,8 @@ struct max77686_clk_init_data { ...@@ -62,9 +62,8 @@ struct max77686_clk_init_data {
struct max77686_clk_driver_data { struct max77686_clk_driver_data {
enum max77686_chip_name chip; enum max77686_chip_name chip;
struct clk **clks;
struct max77686_clk_init_data *max_clk_data; struct max77686_clk_init_data *max_clk_data;
struct clk_onecell_data of_data; size_t num_clks;
}; };
static const struct static const struct
...@@ -160,6 +159,20 @@ static struct clk_ops max77686_clk_ops = { ...@@ -160,6 +159,20 @@ static struct clk_ops max77686_clk_ops = {
.recalc_rate = max77686_recalc_rate, .recalc_rate = max77686_recalc_rate,
}; };
static struct clk_hw *
of_clk_max77686_get(struct of_phandle_args *clkspec, void *data)
{
struct max77686_clk_driver_data *drv_data = data;
unsigned int idx = clkspec->args[0];
if (idx >= drv_data->num_clks) {
pr_err("%s: invalid index %u\n", __func__, idx);
return ERR_PTR(-EINVAL);
}
return &drv_data->max_clk_data[idx].hw;
}
static int max77686_clk_probe(struct platform_device *pdev) static int max77686_clk_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
...@@ -209,14 +222,8 @@ static int max77686_clk_probe(struct platform_device *pdev) ...@@ -209,14 +222,8 @@ static int max77686_clk_probe(struct platform_device *pdev)
if (!drv_data->max_clk_data) if (!drv_data->max_clk_data)
return -ENOMEM; return -ENOMEM;
drv_data->clks = devm_kcalloc(dev, num_clks,
sizeof(*drv_data->clks), GFP_KERNEL);
if (!drv_data->clks)
return -ENOMEM;
for (i = 0; i < num_clks; i++) { for (i = 0; i < num_clks; i++) {
struct max77686_clk_init_data *max_clk_data; struct max77686_clk_init_data *max_clk_data;
struct clk *clk;
const char *clk_name; const char *clk_name;
max_clk_data = &drv_data->max_clk_data[i]; max_clk_data = &drv_data->max_clk_data[i];
...@@ -236,30 +243,23 @@ static int max77686_clk_probe(struct platform_device *pdev) ...@@ -236,30 +243,23 @@ static int max77686_clk_probe(struct platform_device *pdev)
max_clk_data->hw.init = &max_clk_data->clk_idata; max_clk_data->hw.init = &max_clk_data->clk_idata;
clk = devm_clk_register(dev, &max_clk_data->hw); ret = devm_clk_hw_register(dev, &max_clk_data->hw);
if (IS_ERR(clk)) { if (ret) {
ret = PTR_ERR(clk);
dev_err(dev, "Failed to clock register: %d\n", ret); dev_err(dev, "Failed to clock register: %d\n", ret);
return ret; return ret;
} }
ret = clk_register_clkdev(clk, max_clk_data->clk_idata.name, ret = clk_hw_register_clkdev(&max_clk_data->hw,
NULL); max_clk_data->clk_idata.name, NULL);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "Failed to clkdev register: %d\n", ret); dev_err(dev, "Failed to clkdev register: %d\n", ret);
return ret; return ret;
} }
drv_data->clks[i] = clk;
} }
platform_set_drvdata(pdev, drv_data);
if (parent->of_node) { if (parent->of_node) {
drv_data->of_data.clks = drv_data->clks; ret = of_clk_add_hw_provider(parent->of_node, of_clk_max77686_get,
drv_data->of_data.clk_num = num_clks; drv_data);
ret = of_clk_add_provider(parent->of_node,
of_clk_src_onecell_get,
&drv_data->of_data);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "Failed to register OF clock provider: %d\n", dev_err(dev, "Failed to register OF clock provider: %d\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment