From: Thorsten Blum <blum@kernel.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>,
Thorsten Blum <blum@kernel.org>, Yury Norov <ynorov@nvidia.com>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] thermal: intel: powerclamp: Simplify max_idle_set()
Date: Wed, 16 Sep 2026 00:15:49 +0200 [thread overview]
Message-ID: <20260915221548.104852-4-blum@kernel.org> (raw)
In-Reply-To: <20260915221548.104852-3-blum@kernel.org>
Use guard(mutex) and return errors directly to simplify the code.
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
drivers/thermal/intel/intel_powerclamp.c | 29 ++++++++----------------
1 file changed, 10 insertions(+), 19 deletions(-)
diff --git a/drivers/thermal/intel/intel_powerclamp.c b/drivers/thermal/intel/intel_powerclamp.c
index 8ceb1270646c..6ca6a082b222 100644
--- a/drivers/thermal/intel/intel_powerclamp.c
+++ b/drivers/thermal/intel/intel_powerclamp.c
@@ -210,41 +210,32 @@ MODULE_PARM_DESC(cpumask, "Mask of CPUs to use for idle injection.");
static int max_idle_set(const char *arg, const struct kernel_param *kp)
{
u8 new_max_idle;
- int ret = 0;
+ int ret;
- mutex_lock(&powerclamp_lock);
+ guard(mutex)(&powerclamp_lock);
/* Can't set mask when cooling device is in use */
- if (powerclamp_data.clamping) {
- ret = -EAGAIN;
- goto skip_limit_set;
- }
+ if (powerclamp_data.clamping)
+ return -EAGAIN;
ret = kstrtou8(arg, 10, &new_max_idle);
if (ret)
- goto skip_limit_set;
+ return ret;
- if (new_max_idle > MAX_TARGET_RATIO) {
- ret = -EINVAL;
- goto skip_limit_set;
- }
+ if (new_max_idle > MAX_TARGET_RATIO)
+ return -EINVAL;
if (!cpumask_available(idle_injection_cpu_mask)) {
ret = allocate_copy_idle_injection_mask(cpu_present_mask);
if (ret)
- goto skip_limit_set;
+ return ret;
}
- if (check_invalid(idle_injection_cpu_mask, new_max_idle)) {
- ret = -EINVAL;
- goto skip_limit_set;
- }
+ if (check_invalid(idle_injection_cpu_mask, new_max_idle))
+ return -EINVAL;
max_idle = new_max_idle;
-skip_limit_set:
- mutex_unlock(&powerclamp_lock);
-
return ret;
}
next prev parent reply other threads:[~2026-09-15 22:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 22:15 [PATCH 1/2] thermal: intel: powerclamp: Simplify duration_get() Thorsten Blum
2026-09-15 22:15 ` Thorsten Blum [this message]
2026-09-25 19:21 ` Rafael J. Wysocki (Intel)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260915221548.104852-4-blum@kernel.org \
--to=blum@kernel.org \
--cc=daniel.lezcano@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael.j.wysocki@intel.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=ynorov@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.