Commit 72ee45fd authored by ye xingchen's avatar ye xingchen Committed by Steve French

ksmbd: Convert to use sysfs_emit()/sysfs_emit_at() APIs

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.
Signed-off-by: default avatarye xingchen <ye.xingchen@zte.com.cn>
Reviewed-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
Acked-by: default avatarNamjae Jeon <linkinjeon@kernel.org>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 01f6c61b
...@@ -432,11 +432,9 @@ static ssize_t stats_show(struct class *class, struct class_attribute *attr, ...@@ -432,11 +432,9 @@ static ssize_t stats_show(struct class *class, struct class_attribute *attr,
"reset", "reset",
"shutdown" "shutdown"
}; };
return sysfs_emit(buf, "%d %s %d %lu\n", stats_version,
ssize_t sz = scnprintf(buf, PAGE_SIZE, "%d %s %d %lu\n", stats_version,
state[server_conf.state], server_conf.tcp_port, state[server_conf.state], server_conf.tcp_port,
server_conf.ipc_last_active / HZ); server_conf.ipc_last_active / HZ);
return sz;
} }
static ssize_t kill_server_store(struct class *class, static ssize_t kill_server_store(struct class *class,
...@@ -468,19 +466,13 @@ static ssize_t debug_show(struct class *class, struct class_attribute *attr, ...@@ -468,19 +466,13 @@ static ssize_t debug_show(struct class *class, struct class_attribute *attr,
for (i = 0; i < ARRAY_SIZE(debug_type_strings); i++) { for (i = 0; i < ARRAY_SIZE(debug_type_strings); i++) {
if ((ksmbd_debug_types >> i) & 1) { if ((ksmbd_debug_types >> i) & 1) {
pos = scnprintf(buf + sz, pos = sysfs_emit_at(buf, sz, "[%s] ", debug_type_strings[i]);
PAGE_SIZE - sz,
"[%s] ",
debug_type_strings[i]);
} else { } else {
pos = scnprintf(buf + sz, pos = sysfs_emit_at(buf, sz, "%s ", debug_type_strings[i]);
PAGE_SIZE - sz,
"%s ",
debug_type_strings[i]);
} }
sz += pos; sz += pos;
} }
sz += scnprintf(buf + sz, PAGE_SIZE - sz, "\n"); sz += sysfs_emit_at(buf, sz, "\n");
return sz; return sz;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment