Skip to contentSkip to conversation

powerpc/sysfs: Remove redundant wait time clamps

PATCH Applied Thorsten Blum 3 participants 3 messages Sep 16 – Sep 29 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/sysfs: Remove redundant wait time clamps

The wait times are u64 and cannot be negative. Remove the redundant clamps.

---
 arch/powerpc/kernel/sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kernel/sysfs.c +2 -2
index 329c1690b5ed..2100c5e2c821 100644
@@ -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)
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Thorsten Blum

The wait times are u64 and cannot be negative. Remove the redundant clamps.

---
 arch/powerpc/kernel/sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kernel/sysfs.c +0 -0
index 329c1690b5ed..2100c5e2c821 100644

arch/powerpc/kernel/sysfs.c static ssize_t show_pw20_wait_time(struct device *dev, · line 341

Quoted 4 lines
arch/powerpc/kernel/sysfs.c +0 -1
@@ -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.

Thanks,
Amit

Quoted 13 lines
arch/powerpc/kernel/sysfs.c +2 -1
+	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)