Skip to contentSkip to conversation

thermal: Convert to use sysfs_emit_at() API

PATCH Applied [email protected] 2 participants 2 messages Jan 17, 2023 – Feb 9, 2023 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal: Convert to use sysfs_emit_at() API

From: ye xingchen <[email protected]>

Follow the advice of the Documentation/filesystems/sysfs.rst and show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space.

---
 drivers/thermal/thermal_core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/thermal/thermal_core.c +2 -3
index d9a3d9566d73..5ffc7006cce4 100644
@@ -229,10 +229,9 @@ int thermal_build_list_of_policies(char *buf)
 	mutex_lock(&thermal_governor_lock);
 
 	list_for_each_entry(pos, &thermal_governor_list, governor_list) {
-		count += scnprintf(buf + count, PAGE_SIZE - count, "%s ",
-				   pos->name);
+		count += sysfs_emit_at(buf, count, "%s ", pos->name);
 	}
-	count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
+	count += sysfs_emit_at(buf, count, "\n");
 
 	mutex_unlock(&thermal_governor_lock);
 
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 20 lines · On Tue, Jan 17, 2023 at 3:40 AM <[email protected]> wrote:

From: ye xingchen <[email protected]>

Follow the advice of the Documentation/filesystems/sysfs.rst and show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space.

---
 drivers/thermal/thermal_core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/thermal/thermal_core.c +0 -0
index d9a3d9566d73..5ffc7006cce4 100644
@@ -229,10 +229,9 @@ int thermal_build_list_of_policies(char *buf)
        mutex_lock(&thermal_governor_lock);
 
        list_for_each_entry(pos, &thermal_governor_list, governor_list) {

drivers/thermal/thermal_core.c int thermal_build_list_of_policies(char *buf)

Quoted 10 lines
drivers/thermal/thermal_core.c +2 -4
-               count += scnprintf(buf + count, PAGE_SIZE - count, "%s ",
-                                  pos->name);
+               count += sysfs_emit_at(buf, count, "%s ", pos->name);
        }
-       count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
+       count += sysfs_emit_at(buf, count, "\n");
 
        mutex_unlock(&thermal_governor_lock);
 
--

Applied as 6.3 material, thanks!