Skip to contentSkip to conversation

w1: therm: Use str_yes_no helper in w1_slave_show

PATCH In review Thorsten Blum 2 participants 3 messages Nov 5, 2025 – Nov 8, 2025 W1 dallas's 1-wire bus

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 w1: therm: Use str_yes_no helper in w1_slave_show

Replace hard-coded strings with the str_yes_no() helper function. This unifies the output and helps the linker with deduplication, which can result in a smaller binary.

---
 drivers/w1/slaves/w1_therm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/w1/slaves/w1_therm.c +2 -1
index 9ccedb3264fb..0b54ab7f237e 100644
@@ -17,6 +17,7 @@
 #include <linux/delay.h>
 #include <linux/hwmon.h>
 #include <linux/string.h>
+#include <linux/string_choices.h>
 #include <linux/jiffies.h>
 
 #include <linux/w1.h>
@@ -1609,7 +1610,7 @@ static ssize_t w1_slave_show(struct device *device,
 	for (i = 0; i < 9; ++i)
 		c -= snprintf(buf + PAGE_SIZE - c, c, "%02x ", info.rom[i]);
 	c -= snprintf(buf + PAGE_SIZE - c, c, ": crc=%02x %s\n",
-		      info.crc, (info.verdict) ? "YES" : "NO");
+		      info.crc, str_yes_no(info.verdict));
 
 	if (info.verdict)
 		memcpy(family_data, info.rom, sizeof(info.rom));
Signature · 1 line
2.51.1
#1 lore raw
Quoted 22 lines · Thorsten Blum

Replace hard-coded strings with the str_yes_no() helper function. This unifies the output and helps the linker with deduplication, which can result in a smaller binary.

---
 drivers/w1/slaves/w1_therm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/w1/slaves/w1_therm.c +1 -0
index 9ccedb3264fb..0b54ab7f237e 100644
@@ -17,6 +17,7 @@
 #include <linux/delay.h>
 #include <linux/hwmon.h>
 #include <linux/string.h>
+#include <linux/string_choices.h>
 #include <linux/jiffies.h>
 
 #include <linux/w1.h>

drivers/w1/slaves/w1_therm.c static ssize_t w1_slave_show(struct device *device, · line 1612

Quoted 4 lines
drivers/w1/slaves/w1_therm.c +0 -1
@@ -1609,7 +1610,7 @@ static ssize_t w1_slave_show(struct device *device,
 	for (i = 0; i < 9; ++i)
 		c -= snprintf(buf + PAGE_SIZE - c, c, "%02x ", info.rom[i]);
 	c -= snprintf(buf + PAGE_SIZE - c, c, ": crc=%02x %s\n",
-		      info.crc, (info.verdict) ? "YES" : "NO");

That's sysfs interface, right? So an ABI and you change here caps, which might matter or might not, but anyway some sort of analysis of that should be in the commit msg. Otherwise better not to touch ABI.

Best regards,
Krzysztof

#2 lore raw
Quoted 10 lines · Krzysztof Kozlowski
Quoted 5 lines · Thorsten Blum

Replace hard-coded strings with the str_yes_no() helper function. This unifies the output and helps the linker with deduplication, which can result in a smaller binary.

[...]

That's sysfs interface, right? So an ABI and you change here caps, which might matter or might not, but anyway some sort of analysis of that should be in the commit msg. Otherwise better not to touch ABI.

Yeah, I guess it's better not to change it then.

Thanks,
Thorsten