Skip to content

Commit 45dac19

Browse files
zhangguopengakpm00
authored andcommitted
kernel/reboot: replace sprintf() with sysfs_emit()
As Documentation/filesystems/sysfs.rst suggested, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. No functional change intended. Link: https://lkml.kernel.org/r/20241105094941.33739-1-zhangguopeng@kylinos.cn Signed-off-by: zhangguopeng <zhangguopeng@kylinos.cn> Cc: Daniel Lezcano <daniel.lezcano@linaro.org> Cc: Fabio Estevam <festevam@denx.de> Cc: Joel Granados <joel.granados@kernel.org> Cc: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 1113141 commit 45dac19

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

kernel/reboot.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ static ssize_t mode_show(struct kobject *kobj, struct kobj_attribute *attr, char
11371137
val = REBOOT_UNDEFINED_STR;
11381138
}
11391139

1140-
return sprintf(buf, "%s\n", val);
1140+
return sysfs_emit(buf, "%s\n", val);
11411141
}
11421142
static ssize_t mode_store(struct kobject *kobj, struct kobj_attribute *attr,
11431143
const char *buf, size_t count)
@@ -1167,7 +1167,7 @@ static struct kobj_attribute reboot_mode_attr = __ATTR_RW(mode);
11671167
#ifdef CONFIG_X86
11681168
static ssize_t force_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
11691169
{
1170-
return sprintf(buf, "%d\n", reboot_force);
1170+
return sysfs_emit(buf, "%d\n", reboot_force);
11711171
}
11721172
static ssize_t force_store(struct kobject *kobj, struct kobj_attribute *attr,
11731173
const char *buf, size_t count)
@@ -1214,7 +1214,7 @@ static ssize_t type_show(struct kobject *kobj, struct kobj_attribute *attr, char
12141214
val = REBOOT_UNDEFINED_STR;
12151215
}
12161216

1217-
return sprintf(buf, "%s\n", val);
1217+
return sysfs_emit(buf, "%s\n", val);
12181218
}
12191219
static ssize_t type_store(struct kobject *kobj, struct kobj_attribute *attr,
12201220
const char *buf, size_t count)
@@ -1247,7 +1247,7 @@ static struct kobj_attribute reboot_type_attr = __ATTR_RW(type);
12471247
#ifdef CONFIG_SMP
12481248
static ssize_t cpu_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
12491249
{
1250-
return sprintf(buf, "%d\n", reboot_cpu);
1250+
return sysfs_emit(buf, "%d\n", reboot_cpu);
12511251
}
12521252
static ssize_t cpu_store(struct kobject *kobj, struct kobj_attribute *attr,
12531253
const char *buf, size_t count)

0 commit comments

Comments
 (0)