[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230308112253.15659-3-sebastian.reichel@collabora.com>
Date: Wed, 8 Mar 2023 12:22:48 +0100
From: Sebastian Reichel <sebastian.reichel@...labora.com>
To: Heiko Stuebner <heiko@...ech.de>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Amit Kucheria <amitk@...nel.org>,
Zhang Rui <rui.zhang@...el.com>
Cc: Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
linux-pm@...r.kernel.org, linux-rockchip@...ts.infradead.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
Sebastian Reichel <sebastian.reichel@...labora.com>,
kernel@...labora.com
Subject: [RESEND] [PATCHv3 2/7] thermal: 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: Heiko Stuebner <heiko@...ech.de>
Signed-off-by: Sebastian Reichel <sebastian.reichel@...labora.com>
---
drivers/thermal/rockchip_thermal.c | 33 +++++-------------------------
1 file changed, 5 insertions(+), 28 deletions(-)
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index 7e88525fe8d0..6235c033995b 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -1383,14 +1383,14 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
return error;
}
- thermal->clk = devm_clk_get(&pdev->dev, "tsadc");
+ thermal->clk = devm_clk_get_enabled(&pdev->dev, "tsadc");
if (IS_ERR(thermal->clk)) {
error = PTR_ERR(thermal->clk);
dev_err(&pdev->dev, "failed to get tsadc clock: %d\n", 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)) {
error = PTR_ERR(thermal->pclk);
dev_err(&pdev->dev, "failed to get apb_pclk clock: %d\n",
@@ -1398,26 +1398,13 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
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);
error = rockchip_configure_from_dt(&pdev->dev, np, thermal);
if (error) {
dev_err(&pdev->dev, "failed to parse device tree data: %d\n",
error);
- goto err_disable_pclk;
+ return error;
}
thermal->chip->initialize(thermal->grf, thermal->regs,
@@ -1431,7 +1418,7 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
dev_err(&pdev->dev,
"failed to register sensor[%d] : error = %d\n",
i, error);
- goto err_disable_pclk;
+ return error;
}
}
@@ -1442,7 +1429,7 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
if (error) {
dev_err(&pdev->dev,
"failed to request tsadc irq: %d\n", error);
- goto err_disable_pclk;
+ return error;
}
thermal->chip->control(thermal->regs, true);
@@ -1460,13 +1447,6 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, thermal);
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)
@@ -1483,9 +1463,6 @@ static int rockchip_thermal_remove(struct platform_device *pdev)
thermal->chip->control(thermal->regs, false);
- clk_disable_unprepare(thermal->pclk);
- clk_disable_unprepare(thermal->clk);
-
return 0;
}
--
2.39.2
Powered by blists - more mailing lists