mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
pmdomain: qcom: rpmpd: Simplify locking with guard()
Simplify error handling (less gotos) over locks with guard(). Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Konrad Dybcio <konradybcio@kernel.org> Link: https://lore.kernel.org/r/20240823-cleanup-h-guard-pm-domain-v1-8-8320722eaf39@linaro.org Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
parent
005d29ac59
commit
f3185222cc
@ -1,6 +1,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. */
|
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. */
|
||||||
|
|
||||||
|
#include <linux/cleanup.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
@ -1024,20 +1025,17 @@ static int rpmpd_power_on(struct generic_pm_domain *domain)
|
|||||||
int ret;
|
int ret;
|
||||||
struct rpmpd *pd = domain_to_rpmpd(domain);
|
struct rpmpd *pd = domain_to_rpmpd(domain);
|
||||||
|
|
||||||
mutex_lock(&rpmpd_lock);
|
guard(mutex)(&rpmpd_lock);
|
||||||
|
|
||||||
ret = rpmpd_send_enable(pd, true);
|
ret = rpmpd_send_enable(pd, true);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
return ret;
|
||||||
|
|
||||||
pd->enabled = true;
|
pd->enabled = true;
|
||||||
|
|
||||||
if (pd->corner)
|
if (pd->corner)
|
||||||
ret = rpmpd_aggregate_corner(pd);
|
ret = rpmpd_aggregate_corner(pd);
|
||||||
|
|
||||||
out:
|
|
||||||
mutex_unlock(&rpmpd_lock);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1060,27 +1058,21 @@ static int rpmpd_power_off(struct generic_pm_domain *domain)
|
|||||||
static int rpmpd_set_performance(struct generic_pm_domain *domain,
|
static int rpmpd_set_performance(struct generic_pm_domain *domain,
|
||||||
unsigned int state)
|
unsigned int state)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
|
||||||
struct rpmpd *pd = domain_to_rpmpd(domain);
|
struct rpmpd *pd = domain_to_rpmpd(domain);
|
||||||
|
|
||||||
if (state > pd->max_state)
|
if (state > pd->max_state)
|
||||||
state = pd->max_state;
|
state = pd->max_state;
|
||||||
|
|
||||||
mutex_lock(&rpmpd_lock);
|
guard(mutex)(&rpmpd_lock);
|
||||||
|
|
||||||
pd->corner = state;
|
pd->corner = state;
|
||||||
|
|
||||||
/* Always send updates for vfc and vfl */
|
/* Always send updates for vfc and vfl */
|
||||||
if (!pd->enabled && pd->key != cpu_to_le32(KEY_FLOOR_CORNER) &&
|
if (!pd->enabled && pd->key != cpu_to_le32(KEY_FLOOR_CORNER) &&
|
||||||
pd->key != cpu_to_le32(KEY_FLOOR_LEVEL))
|
pd->key != cpu_to_le32(KEY_FLOOR_LEVEL))
|
||||||
goto out;
|
return 0;
|
||||||
|
|
||||||
ret = rpmpd_aggregate_corner(pd);
|
return rpmpd_aggregate_corner(pd);
|
||||||
|
|
||||||
out:
|
|
||||||
mutex_unlock(&rpmpd_lock);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rpmpd_probe(struct platform_device *pdev)
|
static int rpmpd_probe(struct platform_device *pdev)
|
||||||
|
Loading…
Reference in New Issue
Block a user