Skip to content

Commit c3bc361

Browse files
ukleinekchanwoochoi
authored andcommitted
PM / devfreq: sun8i-a33-mbus: Simplify by using more devm functions
Use devm allocators for enabling the bus clock and clk_rate_exclusive_get(). This simplifies error handling and the remove callback. Reviewed-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Tested-by: Corentin LABBE <clabbe.montjoie@gmail.com> Link: https://patchwork.kernel.org/project/linux-pm/patch/20250513203908.205060-2-u.kleine-koenig@baylibre.com/ Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
1 parent 78c5845 commit c3bc361

1 file changed

Lines changed: 9 additions & 29 deletions

File tree

drivers/devfreq/sun8i-a33-mbus.c

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static int sun8i_a33_mbus_probe(struct platform_device *pdev)
360360
if (IS_ERR(priv->reg_mbus))
361361
return PTR_ERR(priv->reg_mbus);
362362

363-
priv->clk_bus = devm_clk_get(dev, "bus");
363+
priv->clk_bus = devm_clk_get_enabled(dev, "bus");
364364
if (IS_ERR(priv->clk_bus))
365365
return dev_err_probe(dev, PTR_ERR(priv->clk_bus),
366366
"failed to get bus clock\n");
@@ -375,24 +375,15 @@ static int sun8i_a33_mbus_probe(struct platform_device *pdev)
375375
return dev_err_probe(dev, PTR_ERR(priv->clk_mbus),
376376
"failed to get mbus clock\n");
377377

378-
ret = clk_prepare_enable(priv->clk_bus);
379-
if (ret)
380-
return dev_err_probe(dev, ret,
381-
"failed to enable bus clock\n");
382-
383378
/* Lock the DRAM clock rate to keep priv->nominal_bw in sync. */
384-
ret = clk_rate_exclusive_get(priv->clk_dram);
385-
if (ret) {
386-
err = "failed to lock dram clock rate\n";
387-
goto err_disable_bus;
388-
}
379+
ret = devm_clk_rate_exclusive_get(dev, priv->clk_dram);
380+
if (ret)
381+
return dev_err_probe(dev, ret, "failed to lock dram clock rate\n");
389382

390383
/* Lock the MBUS clock rate to keep MBUS_TMR_PERIOD in sync. */
391-
ret = clk_rate_exclusive_get(priv->clk_mbus);
392-
if (ret) {
393-
err = "failed to lock mbus clock rate\n";
394-
goto err_unlock_dram;
395-
}
384+
ret = devm_clk_rate_exclusive_get(dev, priv->clk_mbus);
385+
if (ret)
386+
return dev_err_probe(dev, ret, "failed to lock mbus clock rate\n");
396387

397388
priv->gov_data.upthreshold = 10;
398389
priv->gov_data.downdifferential = 5;
@@ -405,10 +396,8 @@ static int sun8i_a33_mbus_probe(struct platform_device *pdev)
405396
priv->profile.max_state = max_state;
406397

407398
ret = devm_pm_opp_set_clkname(dev, "dram");
408-
if (ret) {
409-
err = "failed to add OPP table\n";
410-
goto err_unlock_mbus;
411-
}
399+
if (ret)
400+
return dev_err_probe(dev, ret, "failed to add OPP table\n");
412401

413402
base_freq = clk_get_rate(clk_get_parent(priv->clk_dram));
414403
for (i = 0; i < max_state; ++i) {
@@ -448,12 +437,6 @@ static int sun8i_a33_mbus_probe(struct platform_device *pdev)
448437

449438
err_remove_opps:
450439
dev_pm_opp_remove_all_dynamic(dev);
451-
err_unlock_mbus:
452-
clk_rate_exclusive_put(priv->clk_mbus);
453-
err_unlock_dram:
454-
clk_rate_exclusive_put(priv->clk_dram);
455-
err_disable_bus:
456-
clk_disable_unprepare(priv->clk_bus);
457440

458441
return dev_err_probe(dev, ret, err);
459442
}
@@ -472,9 +455,6 @@ static void sun8i_a33_mbus_remove(struct platform_device *pdev)
472455
dev_warn(dev, "failed to restore DRAM frequency: %d\n", ret);
473456

474457
dev_pm_opp_remove_all_dynamic(dev);
475-
clk_rate_exclusive_put(priv->clk_mbus);
476-
clk_rate_exclusive_put(priv->clk_dram);
477-
clk_disable_unprepare(priv->clk_bus);
478458
}
479459

480460
static const struct sun8i_a33_mbus_variant sun50i_a64_mbus = {

0 commit comments

Comments
 (0)