Commit 2f6916f1 authored by Sebastian Reichel's avatar Sebastian Reichel Committed by Daniel Lezcano

thermal/drivers/rockchip: Simplify clock logic

By using devm_clk_get_enabled() the clock acquisition and
enabling can be done in one step with automatic error
handling.
Reviewed-by: default avatarHeiko Stuebner <heiko@sntech.de>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20230308112253.15659-3-sebastian.reichel@collabora.com
parent f1d2427c
...@@ -1380,14 +1380,14 @@ static int rockchip_thermal_probe(struct platform_device *pdev) ...@@ -1380,14 +1380,14 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
return error; return error;
} }
thermal->clk = devm_clk_get(&pdev->dev, "tsadc"); thermal->clk = devm_clk_get_enabled(&pdev->dev, "tsadc");
if (IS_ERR(thermal->clk)) { if (IS_ERR(thermal->clk)) {
error = PTR_ERR(thermal->clk); error = PTR_ERR(thermal->clk);
dev_err(&pdev->dev, "failed to get tsadc clock: %d\n", error); dev_err(&pdev->dev, "failed to get tsadc clock: %d\n", error);
return error; return error;
} }
thermal->pclk = devm_clk_get(&pdev->dev, "apb_pclk"); thermal->pclk = devm_clk_get_enabled(&pdev->dev, "apb_pclk");
if (IS_ERR(thermal->pclk)) { if (IS_ERR(thermal->pclk)) {
error = PTR_ERR(thermal->pclk); error = PTR_ERR(thermal->pclk);
dev_err(&pdev->dev, "failed to get apb_pclk clock: %d\n", dev_err(&pdev->dev, "failed to get apb_pclk clock: %d\n",
...@@ -1395,26 +1395,13 @@ static int rockchip_thermal_probe(struct platform_device *pdev) ...@@ -1395,26 +1395,13 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
return error; return error;
} }
error = clk_prepare_enable(thermal->clk);
if (error) {
dev_err(&pdev->dev, "failed to enable converter clock: %d\n",
error);
return error;
}
error = clk_prepare_enable(thermal->pclk);
if (error) {
dev_err(&pdev->dev, "failed to enable pclk: %d\n", error);
goto err_disable_clk;
}
rockchip_thermal_reset_controller(thermal->reset); rockchip_thermal_reset_controller(thermal->reset);
error = rockchip_configure_from_dt(&pdev->dev, np, thermal); error = rockchip_configure_from_dt(&pdev->dev, np, thermal);
if (error) { if (error) {
dev_err(&pdev->dev, "failed to parse device tree data: %d\n", dev_err(&pdev->dev, "failed to parse device tree data: %d\n",
error); error);
goto err_disable_pclk; return error;
} }
thermal->chip->initialize(thermal->grf, thermal->regs, thermal->chip->initialize(thermal->grf, thermal->regs,
...@@ -1428,7 +1415,7 @@ static int rockchip_thermal_probe(struct platform_device *pdev) ...@@ -1428,7 +1415,7 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
dev_err(&pdev->dev, dev_err(&pdev->dev,
"failed to register sensor[%d] : error = %d\n", "failed to register sensor[%d] : error = %d\n",
i, error); i, error);
goto err_disable_pclk; return error;
} }
} }
...@@ -1439,7 +1426,7 @@ static int rockchip_thermal_probe(struct platform_device *pdev) ...@@ -1439,7 +1426,7 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
if (error) { if (error) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"failed to request tsadc irq: %d\n", error); "failed to request tsadc irq: %d\n", error);
goto err_disable_pclk; return error;
} }
thermal->chip->control(thermal->regs, true); thermal->chip->control(thermal->regs, true);
...@@ -1456,13 +1443,6 @@ static int rockchip_thermal_probe(struct platform_device *pdev) ...@@ -1456,13 +1443,6 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, thermal); platform_set_drvdata(pdev, thermal);
return 0; return 0;
err_disable_pclk:
clk_disable_unprepare(thermal->pclk);
err_disable_clk:
clk_disable_unprepare(thermal->clk);
return error;
} }
static int rockchip_thermal_remove(struct platform_device *pdev) static int rockchip_thermal_remove(struct platform_device *pdev)
...@@ -1479,9 +1459,6 @@ static int rockchip_thermal_remove(struct platform_device *pdev) ...@@ -1479,9 +1459,6 @@ static int rockchip_thermal_remove(struct platform_device *pdev)
thermal->chip->control(thermal->regs, false); thermal->chip->control(thermal->regs, false);
clk_disable_unprepare(thermal->pclk);
clk_disable_unprepare(thermal->clk);
return 0; return 0;
} }
......
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