From: Amit Machhiwal <amachhiw@linux.ibm.com>
To: Thorsten Blum <blum@kernel.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] powerpc/sysfs: Remove redundant wait time clamps
Date: Wed, 16 Sep 2026 21:02:13 +0530 [thread overview]
Message-ID: <20260916205928.ed6f9a7e-66-amachhiw@linux.ibm.com> (raw)
In-Reply-To: <20260916151254.120629-2-blum@kernel.org>
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)
prev parent reply other threads:[~2026-09-16 15:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 15:12 Thorsten Blum
2026-09-16 15:32 ` Amit Machhiwal [this message]
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=20260916205928.ed6f9a7e-66-amachhiw@linux.ibm.com \
--to=amachhiw@linux.ibm.com \
--cc=blum@kernel.org \
--cc=chleroy@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=ritesh.list@gmail.com \
--cc=sshegde@linux.ibm.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 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®