* [PATCH] powerpc/sysfs: Remove redundant wait time clamps
@ 2026-09-16 15:12 Thorsten Blum
2026-09-16 15:32 ` Amit Machhiwal
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-09-16 15:12 UTC (permalink / raw)
To: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Ritesh Harjani (IBM),
Shrikanth Hegde, Thorsten Blum
Cc: linuxppc-dev, linux-kernel
The wait times are u64 and cannot be negative. Remove the redundant
clamps.
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
arch/powerpc/kernel/sysfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 329c1690b5ed..2100c5e2c821 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -338,7 +338,7 @@ static ssize_t show_pw20_wait_time(struct device *dev,
time = pw20_wt;
}
- return sysfs_emit(buf, "%llu\n", time > 0 ? time : 0);
+ return sysfs_emit(buf, "%llu\n", time);
}
static void set_pw20_wait_entry_bit(void *val)
@@ -460,7 +460,7 @@ static ssize_t show_altivec_idle_wait_time(struct device *dev,
time = altivec_idle_wt;
}
- return sysfs_emit(buf, "%llu\n", time > 0 ? time : 0);
+ return sysfs_emit(buf, "%llu\n", time);
}
static void set_altivec_idle_wait_entry_bit(void *val)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] powerpc/sysfs: Remove redundant wait time clamps
2026-09-16 15:12 [PATCH] powerpc/sysfs: Remove redundant wait time clamps Thorsten Blum
@ 2026-09-16 15:32 ` Amit Machhiwal
0 siblings, 0 replies; 2+ messages in thread
From: Amit Machhiwal @ 2026-09-16 15:32 UTC (permalink / raw)
To: Thorsten Blum
Cc: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Ritesh Harjani (IBM),
Shrikanth Hegde, linuxppc-dev, linux-kernel
On 2026/09/16 05:12 PM, Thorsten Blum wrote:
> The wait times are u64 and cannot be negative. Remove the redundant
> clamps.
>
> Signed-off-by: Thorsten Blum <blum@kernel.org>
> ---
> arch/powerpc/kernel/sysfs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
> index 329c1690b5ed..2100c5e2c821 100644
> --- a/arch/powerpc/kernel/sysfs.c
> +++ b/arch/powerpc/kernel/sysfs.c
> @@ -338,7 +338,7 @@ static ssize_t show_pw20_wait_time(struct device *dev,
> time = pw20_wt;
> }
>
> - return sysfs_emit(buf, "%llu\n", time > 0 ? time : 0);
The time variables in both show_pw20_wait_time() and show_altivec_idle_wait_time()
are u64, so the expression time > 0 ? time : 0 is indeed a no-op for all
possible values — when time == 0 the ternary also yields 0, and negative values
are impossible by type. The simplification is correct and removes a subtly
misleading pattern that implies a signed type.
Nit: the commit message could also mention that when time == 0, the ternary
still yields 0, making the conditional identity-preserving for all possible
inputs — not just the non-negative ones. Strengthens the rationale a little,
but not a blocker.
Reviewed-by: Amit Machhiwal <amachhiw@linux.ibm.com>
Thanks,
Amit
> + return sysfs_emit(buf, "%llu\n", time);
> }
>
> static void set_pw20_wait_entry_bit(void *val)
> @@ -460,7 +460,7 @@ static ssize_t show_altivec_idle_wait_time(struct device *dev,
> time = altivec_idle_wt;
> }
>
> - return sysfs_emit(buf, "%llu\n", time > 0 ? time : 0);
> + return sysfs_emit(buf, "%llu\n", time);
> }
>
> static void set_altivec_idle_wait_entry_bit(void *val)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-16 15:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 15:12 [PATCH] powerpc/sysfs: Remove redundant wait time clamps Thorsten Blum
2026-09-16 15:32 ` Amit Machhiwal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®