Commit 93ae00be authored by Stephen Boyd's avatar Stephen Boyd Committed by Stephen Boyd

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: default avatarStephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
parent a8b6e85d
...@@ -146,13 +146,13 @@ static const struct of_device_id scpi_clk_match[] = { ...@@ -146,13 +146,13 @@ static const struct of_device_id scpi_clk_match[] = {
{} {}
}; };
static struct clk * static int
scpi_clk_ops_init(struct device *dev, const struct of_device_id *match, scpi_clk_ops_init(struct device *dev, const struct of_device_id *match,
struct scpi_clk *sclk, const char *name) struct scpi_clk *sclk, const char *name)
{ {
struct clk_init_data init; struct clk_init_data init;
struct clk *clk;
unsigned long min = 0, max = 0; unsigned long min = 0, max = 0;
int ret;
init.name = name; init.name = name;
init.flags = 0; init.flags = 0;
...@@ -164,18 +164,18 @@ scpi_clk_ops_init(struct device *dev, const struct of_device_id *match, ...@@ -164,18 +164,18 @@ scpi_clk_ops_init(struct device *dev, const struct of_device_id *match,
if (init.ops == &scpi_dvfs_ops) { if (init.ops == &scpi_dvfs_ops) {
sclk->info = sclk->scpi_ops->dvfs_get_info(sclk->id); sclk->info = sclk->scpi_ops->dvfs_get_info(sclk->id);
if (IS_ERR(sclk->info)) if (IS_ERR(sclk->info))
return NULL; return PTR_ERR(sclk->info);
} else if (init.ops == &scpi_clk_ops) { } else if (init.ops == &scpi_clk_ops) {
if (sclk->scpi_ops->clk_get_range(sclk->id, &min, &max) || !max) if (sclk->scpi_ops->clk_get_range(sclk->id, &min, &max) || !max)
return NULL; return -EINVAL;
} else { } else {
return NULL; return -EINVAL;
} }
clk = devm_clk_register(dev, &sclk->hw); ret = devm_clk_hw_register(dev, &sclk->hw);
if (!IS_ERR(clk) && max) if (!ret && max)
clk_hw_set_rate_range(&sclk->hw, min, max); clk_hw_set_rate_range(&sclk->hw, min, max);
return clk; return ret;
} }
struct scpi_clk_data { struct scpi_clk_data {
...@@ -183,7 +183,7 @@ struct scpi_clk_data { ...@@ -183,7 +183,7 @@ struct scpi_clk_data {
unsigned int clk_num; unsigned int clk_num;
}; };
static struct clk * static struct clk_hw *
scpi_of_clk_src_get(struct of_phandle_args *clkspec, void *data) scpi_of_clk_src_get(struct of_phandle_args *clkspec, void *data)
{ {
struct scpi_clk *sclk; struct scpi_clk *sclk;
...@@ -193,7 +193,7 @@ scpi_of_clk_src_get(struct of_phandle_args *clkspec, void *data) ...@@ -193,7 +193,7 @@ scpi_of_clk_src_get(struct of_phandle_args *clkspec, void *data)
for (count = 0; count < clk_data->clk_num; count++) { for (count = 0; count < clk_data->clk_num; count++) {
sclk = clk_data->clk[count]; sclk = clk_data->clk[count];
if (idx == sclk->id) if (idx == sclk->id)
return sclk->hw.clk; return &sclk->hw;
} }
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
...@@ -202,8 +202,7 @@ scpi_of_clk_src_get(struct of_phandle_args *clkspec, void *data) ...@@ -202,8 +202,7 @@ scpi_of_clk_src_get(struct of_phandle_args *clkspec, void *data)
static int scpi_clk_add(struct device *dev, struct device_node *np, static int scpi_clk_add(struct device *dev, struct device_node *np,
const struct of_device_id *match) const struct of_device_id *match)
{ {
struct clk **clks; int idx, count, err;
int idx, count;
struct scpi_clk_data *clk_data; struct scpi_clk_data *clk_data;
count = of_property_count_strings(np, "clock-output-names"); count = of_property_count_strings(np, "clock-output-names");
...@@ -222,10 +221,6 @@ static int scpi_clk_add(struct device *dev, struct device_node *np, ...@@ -222,10 +221,6 @@ static int scpi_clk_add(struct device *dev, struct device_node *np,
if (!clk_data->clk) if (!clk_data->clk)
return -ENOMEM; return -ENOMEM;
clks = devm_kcalloc(dev, count, sizeof(*clks), GFP_KERNEL);
if (!clks)
return -ENOMEM;
for (idx = 0; idx < count; idx++) { for (idx = 0; idx < count; idx++) {
struct scpi_clk *sclk; struct scpi_clk *sclk;
const char *name; const char *name;
...@@ -249,15 +244,15 @@ static int scpi_clk_add(struct device *dev, struct device_node *np, ...@@ -249,15 +244,15 @@ static int scpi_clk_add(struct device *dev, struct device_node *np,
sclk->id = val; sclk->id = val;
clks[idx] = scpi_clk_ops_init(dev, match, sclk, name); err = scpi_clk_ops_init(dev, match, sclk, name);
if (IS_ERR_OR_NULL(clks[idx])) if (err)
dev_err(dev, "failed to register clock '%s'\n", name); dev_err(dev, "failed to register clock '%s'\n", name);
else else
dev_dbg(dev, "Registered clock '%s'\n", name); dev_dbg(dev, "Registered clock '%s'\n", name);
clk_data->clk[idx] = sclk; clk_data->clk[idx] = sclk;
} }
return of_clk_add_provider(np, scpi_of_clk_src_get, clk_data); return of_clk_add_hw_provider(np, scpi_of_clk_src_get, clk_data);
} }
static int scpi_clocks_remove(struct platform_device *pdev) static int scpi_clocks_remove(struct platform_device *pdev)
......
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