Skip to content

Commit 629277b

Browse files
moonlinuxchanwoochoi
authored andcommitted
PM / devfreq: exynos: Use Use devm_clk_get_enabled() helpers
The devm_clk_get_enabled() helpers: - call devm_clk_get() - call clk_prepare_enable() and register what is needed in order to call clk_disable_unprepare() when needed, as a managed resource. This simplifies the code and avoids the calls to clk_disable_unprepare(). While at it, use dev_err_probe consistently, and use its return value to return the error code. Link: https://lore.kernel.org/lkml/[email protected]/ Signed-off-by: Anand Moon <[email protected]> Signed-off-by: Chanwoo Choi <[email protected]>
1 parent 53e4e2b commit 629277b

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

drivers/devfreq/exynos-bus.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ static void exynos_bus_exit(struct device *dev)
160160
platform_device_unregister(bus->icc_pdev);
161161

162162
dev_pm_opp_of_remove_table(dev);
163-
clk_disable_unprepare(bus->clk);
164163
dev_pm_opp_put_regulators(bus->opp_token);
165164
}
166165

@@ -171,7 +170,6 @@ static void exynos_bus_passive_exit(struct device *dev)
171170
platform_device_unregister(bus->icc_pdev);
172171

173172
dev_pm_opp_of_remove_table(dev);
174-
clk_disable_unprepare(bus->clk);
175173
}
176174

177175
static int exynos_bus_parent_parse_of(struct device_node *np,
@@ -247,23 +245,16 @@ static int exynos_bus_parse_of(struct device_node *np,
247245
int ret;
248246

249247
/* Get the clock to provide each bus with source clock */
250-
bus->clk = devm_clk_get(dev, "bus");
251-
if (IS_ERR(bus->clk)) {
252-
dev_err(dev, "failed to get bus clock\n");
253-
return PTR_ERR(bus->clk);
254-
}
255-
256-
ret = clk_prepare_enable(bus->clk);
257-
if (ret < 0) {
258-
dev_err(dev, "failed to get enable clock\n");
259-
return ret;
260-
}
248+
bus->clk = devm_clk_get_enabled(dev, "bus");
249+
if (IS_ERR(bus->clk))
250+
return dev_err_probe(dev, PTR_ERR(bus->clk),
251+
"failed to get bus clock\n");
261252

262253
/* Get the freq and voltage from OPP table to scale the bus freq */
263254
ret = dev_pm_opp_of_add_table(dev);
264255
if (ret < 0) {
265256
dev_err(dev, "failed to get OPP table\n");
266-
goto err_clk;
257+
return ret;
267258
}
268259

269260
rate = clk_get_rate(bus->clk);
@@ -281,8 +272,6 @@ static int exynos_bus_parse_of(struct device_node *np,
281272

282273
err_opp:
283274
dev_pm_opp_of_remove_table(dev);
284-
err_clk:
285-
clk_disable_unprepare(bus->clk);
286275

287276
return ret;
288277
}
@@ -453,7 +442,6 @@ static int exynos_bus_probe(struct platform_device *pdev)
453442

454443
err:
455444
dev_pm_opp_of_remove_table(dev);
456-
clk_disable_unprepare(bus->clk);
457445
err_reg:
458446
dev_pm_opp_put_regulators(bus->opp_token);
459447

0 commit comments

Comments
 (0)