* [PATCH 1/2] thermal: intel: powerclamp: Simplify duration_get()
@ 2026-09-15 22:15 Thorsten Blum
2026-09-15 22:15 ` [PATCH 2/2] thermal: intel: powerclamp: Simplify max_idle_set() Thorsten Blum
2026-09-25 19:21 ` [PATCH 1/2] thermal: intel: powerclamp: Simplify duration_get() Rafael J. Wysocki (Intel)
0 siblings, 2 replies; 3+ messages in thread
From: Thorsten Blum @ 2026-09-15 22:15 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Thorsten Blum, Yury Norov
Cc: Rafael J. Wysocki, linux-pm, linux-kernel
Use guard(mutex) and return the result of sysfs_emit() directly to
simplify the code. Also use %u to format the unsigned duration.
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
drivers/thermal/intel/intel_powerclamp.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/thermal/intel/intel_powerclamp.c b/drivers/thermal/intel/intel_powerclamp.c
index bd7fd98dc310..8ceb1270646c 100644
--- a/drivers/thermal/intel/intel_powerclamp.c
+++ b/drivers/thermal/intel/intel_powerclamp.c
@@ -103,13 +103,9 @@ static int duration_set(const char *arg, const struct kernel_param *kp)
static int duration_get(char *buf, const struct kernel_param *kp)
{
- int ret;
+ guard(mutex)(&powerclamp_lock);
- mutex_lock(&powerclamp_lock);
- ret = sysfs_emit(buf, "%d\n", duration / 1000);
- mutex_unlock(&powerclamp_lock);
-
- return ret;
+ return sysfs_emit(buf, "%u\n", duration / 1000);
}
static const struct kernel_param_ops duration_ops = {
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] thermal: intel: powerclamp: Simplify max_idle_set()
2026-09-15 22:15 [PATCH 1/2] thermal: intel: powerclamp: Simplify duration_get() Thorsten Blum
@ 2026-09-15 22:15 ` Thorsten Blum
2026-09-25 19:21 ` [PATCH 1/2] thermal: intel: powerclamp: Simplify duration_get() Rafael J. Wysocki (Intel)
1 sibling, 0 replies; 3+ messages in thread
From: Thorsten Blum @ 2026-09-15 22:15 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Thorsten Blum, Yury Norov
Cc: Rafael J. Wysocki, linux-pm, linux-kernel
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;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] thermal: intel: powerclamp: Simplify duration_get()
2026-09-15 22:15 [PATCH 1/2] thermal: intel: powerclamp: Simplify duration_get() Thorsten Blum
2026-09-15 22:15 ` [PATCH 2/2] thermal: intel: powerclamp: Simplify max_idle_set() Thorsten Blum
@ 2026-09-25 19:21 ` Rafael J. Wysocki (Intel)
1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki (Intel) @ 2026-09-25 19:21 UTC (permalink / raw)
To: Thorsten Blum
Cc: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Yury Norov, Rafael J. Wysocki, linux-pm, linux-kernel
On Wed, Sep 16, 2026 at 12:16 AM Thorsten Blum <blum@kernel.org> wrote:
>
> Use guard(mutex) and return the result of sysfs_emit() directly to
> simplify the code. Also use %u to format the unsigned duration.
>
> Signed-off-by: Thorsten Blum <blum@kernel.org>
> ---
> drivers/thermal/intel/intel_powerclamp.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/thermal/intel/intel_powerclamp.c b/drivers/thermal/intel/intel_powerclamp.c
> index bd7fd98dc310..8ceb1270646c 100644
> --- a/drivers/thermal/intel/intel_powerclamp.c
> +++ b/drivers/thermal/intel/intel_powerclamp.c
> @@ -103,13 +103,9 @@ static int duration_set(const char *arg, const struct kernel_param *kp)
>
> static int duration_get(char *buf, const struct kernel_param *kp)
> {
> - int ret;
> + guard(mutex)(&powerclamp_lock);
>
> - mutex_lock(&powerclamp_lock);
> - ret = sysfs_emit(buf, "%d\n", duration / 1000);
> - mutex_unlock(&powerclamp_lock);
> -
> - return ret;
> + return sysfs_emit(buf, "%u\n", duration / 1000);
> }
>
> static const struct kernel_param_ops duration_ops = {
Applied as 7.4 material along with the [2/2], thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-25 19:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-15 22:15 [PATCH 1/2] thermal: intel: powerclamp: Simplify duration_get() Thorsten Blum
2026-09-15 22:15 ` [PATCH 2/2] thermal: intel: powerclamp: Simplify max_idle_set() Thorsten Blum
2026-09-25 19:21 ` [PATCH 1/2] thermal: intel: powerclamp: Simplify duration_get() Rafael J. Wysocki (Intel)
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.