thermal: core: Use sysfs_emit_at() instead of scnprintf()
authorye xingchen <ye.xingchen@zte.com.cn>
Tue, 17 Jan 2023 02:40:26 +0000 (10:40 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 9 Feb 2023 19:39:48 +0000 (20:39 +0100)
Follow the advice in Documentation/filesystems/sysfs.rst that show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/thermal_core.c

index 0675df54c8e6d021bcb61337f26a56353eb83677..55679fd86505d762ea05ec68028e1a500aec0b5d 100644 (file)
@@ -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);