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>
This commit is contained in:
parent
78c5845fbb
commit
c3bc361393
|
@ -360,7 +360,7 @@ static int sun8i_a33_mbus_probe(struct platform_device *pdev)
|
|||
if (IS_ERR(priv->reg_mbus))
|
||||
return PTR_ERR(priv->reg_mbus);
|
||||
|
||||
priv->clk_bus = devm_clk_get(dev, "bus");
|
||||
priv->clk_bus = devm_clk_get_enabled(dev, "bus");
|
||||
if (IS_ERR(priv->clk_bus))
|
||||
return dev_err_probe(dev, PTR_ERR(priv->clk_bus),
|
||||
"failed to get bus clock\n");
|
||||
|
@ -375,24 +375,15 @@ static int sun8i_a33_mbus_probe(struct platform_device *pdev)
|
|||
return dev_err_probe(dev, PTR_ERR(priv->clk_mbus),
|
||||
"failed to get mbus clock\n");
|
||||
|
||||
ret = clk_prepare_enable(priv->clk_bus);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret,
|
||||
"failed to enable bus clock\n");
|
||||
|
||||
/* Lock the DRAM clock rate to keep priv->nominal_bw in sync. */
|
||||
ret = clk_rate_exclusive_get(priv->clk_dram);
|
||||
if (ret) {
|
||||
err = "failed to lock dram clock rate\n";
|
||||
goto err_disable_bus;
|
||||
}
|
||||
ret = devm_clk_rate_exclusive_get(dev, priv->clk_dram);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "failed to lock dram clock rate\n");
|
||||
|
||||
/* Lock the MBUS clock rate to keep MBUS_TMR_PERIOD in sync. */
|
||||
ret = clk_rate_exclusive_get(priv->clk_mbus);
|
||||
if (ret) {
|
||||
err = "failed to lock mbus clock rate\n";
|
||||
goto err_unlock_dram;
|
||||
}
|
||||
ret = devm_clk_rate_exclusive_get(dev, priv->clk_mbus);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "failed to lock mbus clock rate\n");
|
||||
|
||||
priv->gov_data.upthreshold = 10;
|
||||
priv->gov_data.downdifferential = 5;
|
||||
|
@ -405,10 +396,8 @@ static int sun8i_a33_mbus_probe(struct platform_device *pdev)
|
|||
priv->profile.max_state = max_state;
|
||||
|
||||
ret = devm_pm_opp_set_clkname(dev, "dram");
|
||||
if (ret) {
|
||||
err = "failed to add OPP table\n";
|
||||
goto err_unlock_mbus;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "failed to add OPP table\n");
|
||||
|
||||
base_freq = clk_get_rate(clk_get_parent(priv->clk_dram));
|
||||
for (i = 0; i < max_state; ++i) {
|
||||
|
@ -448,12 +437,6 @@ static int sun8i_a33_mbus_probe(struct platform_device *pdev)
|
|||
|
||||
err_remove_opps:
|
||||
dev_pm_opp_remove_all_dynamic(dev);
|
||||
err_unlock_mbus:
|
||||
clk_rate_exclusive_put(priv->clk_mbus);
|
||||
err_unlock_dram:
|
||||
clk_rate_exclusive_put(priv->clk_dram);
|
||||
err_disable_bus:
|
||||
clk_disable_unprepare(priv->clk_bus);
|
||||
|
||||
return dev_err_probe(dev, ret, err);
|
||||
}
|
||||
|
@ -472,9 +455,6 @@ static void sun8i_a33_mbus_remove(struct platform_device *pdev)
|
|||
dev_warn(dev, "failed to restore DRAM frequency: %d\n", ret);
|
||||
|
||||
dev_pm_opp_remove_all_dynamic(dev);
|
||||
clk_rate_exclusive_put(priv->clk_mbus);
|
||||
clk_rate_exclusive_put(priv->clk_dram);
|
||||
clk_disable_unprepare(priv->clk_bus);
|
||||
}
|
||||
|
||||
static const struct sun8i_a33_mbus_variant sun50i_a64_mbus = {
|
||||
|
|
Loading…
Reference in New Issue