Skip to content

Commit

Permalink
ksmbd: Convert to use sysfs_emit()/sysfs_emit_at() APIs
Browse files Browse the repository at this point in the history
[ Upstream commit 72ee45f ]

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: ye xingchen <ye.xingchen@zte.com.cn>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
ye xingchen authored and gregkh committed Jan 5, 2024
1 parent 87ffbb9 commit 264547e
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions fs/smb/server/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,9 @@ static ssize_t stats_show(struct class *class, struct class_attribute *attr,
"reset",
"shutdown"
};

ssize_t sz = scnprintf(buf, PAGE_SIZE, "%d %s %d %lu\n", stats_version,
state[server_conf.state], server_conf.tcp_port,
server_conf.ipc_last_active / HZ);
return sz;
return sysfs_emit(buf, "%d %s %d %lu\n", stats_version,
state[server_conf.state], server_conf.tcp_port,
server_conf.ipc_last_active / HZ);
}

static ssize_t kill_server_store(struct class *class,
Expand Down Expand Up @@ -478,19 +476,13 @@ static ssize_t debug_show(struct class *class, struct class_attribute *attr,

for (i = 0; i < ARRAY_SIZE(debug_type_strings); i++) {
if ((ksmbd_debug_types >> i) & 1) {
pos = scnprintf(buf + sz,
PAGE_SIZE - sz,
"[%s] ",
debug_type_strings[i]);
pos = sysfs_emit_at(buf, sz, "[%s] ", debug_type_strings[i]);
} else {
pos = scnprintf(buf + sz,
PAGE_SIZE - sz,
"%s ",
debug_type_strings[i]);
pos = sysfs_emit_at(buf, sz, "%s ", debug_type_strings[i]);
}
sz += pos;
}
sz += scnprintf(buf + sz, PAGE_SIZE - sz, "\n");
sz += sysfs_emit_at(buf, sz, "\n");
return sz;
}

Expand Down

0 comments on commit 264547e

Please sign in to comment.