Skip to content

Commit f318522

Browse files
krzkstorulf
authored andcommitted
pmdomain: qcom: rpmpd: 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 005d29a commit f318522

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

drivers/pmdomain/qcom/rpmpd.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/* Copyright (c) 2017-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>
@@ -1024,20 +1025,17 @@ static int rpmpd_power_on(struct generic_pm_domain *domain)
10241025
int ret;
10251026
struct rpmpd *pd = domain_to_rpmpd(domain);
10261027

1027-
mutex_lock(&rpmpd_lock);
1028+
guard(mutex)(&rpmpd_lock);
10281029

10291030
ret = rpmpd_send_enable(pd, true);
10301031
if (ret)
1031-
goto out;
1032+
return ret;
10321033

10331034
pd->enabled = true;
10341035

10351036
if (pd->corner)
10361037
ret = rpmpd_aggregate_corner(pd);
10371038

1038-
out:
1039-
mutex_unlock(&rpmpd_lock);
1040-
10411039
return ret;
10421040
}
10431041

@@ -1060,27 +1058,21 @@ static int rpmpd_power_off(struct generic_pm_domain *domain)
10601058
static int rpmpd_set_performance(struct generic_pm_domain *domain,
10611059
unsigned int state)
10621060
{
1063-
int ret = 0;
10641061
struct rpmpd *pd = domain_to_rpmpd(domain);
10651062

10661063
if (state > pd->max_state)
10671064
state = pd->max_state;
10681065

1069-
mutex_lock(&rpmpd_lock);
1066+
guard(mutex)(&rpmpd_lock);
10701067

10711068
pd->corner = state;
10721069

10731070
/* Always send updates for vfc and vfl */
10741071
if (!pd->enabled && pd->key != cpu_to_le32(KEY_FLOOR_CORNER) &&
10751072
pd->key != cpu_to_le32(KEY_FLOOR_LEVEL))
1076-
goto out;
1073+
return 0;
10771074

1078-
ret = rpmpd_aggregate_corner(pd);
1079-
1080-
out:
1081-
mutex_unlock(&rpmpd_lock);
1082-
1083-
return ret;
1075+
return rpmpd_aggregate_corner(pd);
10841076
}
10851077

10861078
static int rpmpd_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)