Skip to content

Commit 005d29a

Browse files
krzkstorulf
authored andcommitted
pmdomain: qcom: rpmhpd: Simplify locking with guard()
Simplify error handling (less gotos) over locks with guard(). Signed-off-by: Krzysztof Kozlowski <[email protected]> Reviewed-by: Konrad Dybcio <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent ba3a65c commit 005d29a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/pmdomain/qcom/rpmhpd.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/* Copyright (c) 2018, The Linux Foundation. All rights reserved.*/
33

4+
#include <linux/cleanup.h>
45
#include <linux/err.h>
56
#include <linux/init.h>
67
#include <linux/kernel.h>
@@ -775,9 +776,9 @@ static int rpmhpd_set_performance_state(struct generic_pm_domain *domain,
775776
unsigned int level)
776777
{
777778
struct rpmhpd *pd = domain_to_rpmhpd(domain);
778-
int ret = 0, i;
779+
int ret, i;
779780

780-
mutex_lock(&rpmhpd_lock);
781+
guard(mutex)(&rpmhpd_lock);
781782

782783
for (i = 0; i < pd->level_count; i++)
783784
if (level <= pd->level[i])
@@ -797,14 +798,12 @@ static int rpmhpd_set_performance_state(struct generic_pm_domain *domain,
797798

798799
ret = rpmhpd_aggregate_corner(pd, i);
799800
if (ret)
800-
goto out;
801+
return ret;
801802
}
802803

803804
pd->corner = i;
804-
out:
805-
mutex_unlock(&rpmhpd_lock);
806805

807-
return ret;
806+
return 0;
808807
}
809808

810809
static int rpmhpd_update_level_mapping(struct rpmhpd *rpmhpd)

0 commit comments

Comments
 (0)