Skip to contentSkip to conversation

thermal: sysfs: Use str_enabled_disabled helper in mode_show

PATCH Applied Thorsten Blum 2 participants 2 messages Mar 11 – Mar 14 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal: sysfs: Use str_enabled_disabled helper in mode_show

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

---
 drivers/thermal/thermal_sysfs.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/thermal/thermal_sysfs.c +3 -4
index 46b3b2df935c..5eecae13f07d 100644
@@ -18,6 +18,7 @@
 #include <linux/err.h>
 #include <linux/slab.h>
 #include <linux/string.h>
+#include <linux/string_choices.h>
 #include <linux/jiffies.h>
 
 #include "thermal_core.h"
@@ -56,10 +57,8 @@ mode_show(struct device *dev, struct device_attribute *attr, char *buf)
 
 	guard(thermal_zone)(tz);
 
-	if (tz->mode == THERMAL_DEVICE_ENABLED)
-		return sysfs_emit(buf, "enabled\n");
-
-	return sysfs_emit(buf, "disabled\n");
+	return sysfs_emit(buf, "%s\n",
+		str_enabled_disabled(tz->mode == THERMAL_DEVICE_ENABLED));
 }
 
 static ssize_t
maintainer Applied
#1 lore raw
Quoted 25 lines · Thorsten Blum

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

---
 drivers/thermal/thermal_sysfs.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/thermal/thermal_sysfs.c +1 -0
index 46b3b2df935c..5eecae13f07d 100644
@@ -18,6 +18,7 @@
 #include <linux/err.h>
 #include <linux/slab.h>
 #include <linux/string.h>
+#include <linux/string_choices.h>
 #include <linux/jiffies.h>
 
 #include "thermal_core.h"
@@ -56,10 +57,8 @@ mode_show(struct device *dev, struct device_attribute *attr, char *buf)
 
        guard(thermal_zone)(tz);

drivers/thermal/thermal_sysfs.c mode_show(struct device *dev, struct device_attribute *attr, char *buf) · line 64

Quoted 10 lines
drivers/thermal/thermal_sysfs.c +2 -4
 
-       if (tz->mode == THERMAL_DEVICE_ENABLED)
-               return sysfs_emit(buf, "enabled\n");
-
-       return sysfs_emit(buf, "disabled\n");
+       return sysfs_emit(buf, "%s\n",
+               str_enabled_disabled(tz->mode == THERMAL_DEVICE_ENABLED));
 }
 
 static ssize_t

Applied as 7.1 material, thanks!