diff mbox series

[v1,2/6] pmdomain: rockchip: cleanup mutex handling in rockchip_pd_power

Message ID 20240910180530.47194-3-sebastian.reichel@collabora.com (mailing list archive)
State New
Headers show
Series Fix RK3588 GPU domain | expand

Commit Message

Sebastian Reichel Sept. 10, 2024, 5:57 p.m. UTC
Use the cleanup infrastructure to handle the mutex, which
slightly improve code readability for this function.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/pmdomain/rockchip/pm-domains.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Heiko Stübner Sept. 10, 2024, 6:23 p.m. UTC | #1
Am Dienstag, 10. September 2024, 19:57:11 CEST schrieb Sebastian Reichel:
> Use the cleanup infrastructure to handle the mutex, which
> slightly improve code readability for this function.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

Reviewed-by: Heiko Stuebner <heiko@sntech.de>

I guess you could make the guard patch the 1st to not add and then
remove the mutex_unlock in the "forward errors" patch.
diff mbox series

Patch

diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
index 0f44d698475b..5e5291dedd28 100644
--- a/drivers/pmdomain/rockchip/pm-domains.c
+++ b/drivers/pmdomain/rockchip/pm-domains.c
@@ -535,13 +535,12 @@  static int rockchip_pd_power(struct rockchip_pm_domain *pd, bool power_on)
 	struct rockchip_pmu *pmu = pd->pmu;
 	int ret;
 
-	mutex_lock(&pmu->mutex);
+	guard(mutex)(&pmu->mutex);
 
 	if (rockchip_pmu_domain_is_on(pd) != power_on) {
 		ret = clk_bulk_enable(pd->num_clks, pd->clks);
 		if (ret < 0) {
 			dev_err(pmu->dev, "failed to enable clocks\n");
-			mutex_unlock(&pmu->mutex);
 			return ret;
 		}
 
@@ -555,7 +554,6 @@  static int rockchip_pd_power(struct rockchip_pm_domain *pd, bool power_on)
 		ret = rockchip_do_pmu_set_power_domain(pd, power_on);
 		if (ret < 0) {
 			clk_bulk_disable(pd->num_clks, pd->clks);
-			mutex_unlock(&pmu->mutex);
 			return ret;
 		}
 
@@ -569,7 +567,6 @@  static int rockchip_pd_power(struct rockchip_pm_domain *pd, bool power_on)
 		clk_bulk_disable(pd->num_clks, pd->clks);
 	}
 
-	mutex_unlock(&pmu->mutex);
 	return 0;
 }