Skip to content

Commit 72ee45f

Browse files
ye xingchensmfrench
authored andcommitted
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: ye xingchen <[email protected]> Reviewed-by: Sergey Senozhatsky <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 01f6c61 commit 72ee45f

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

fs/ksmbd/server.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,9 @@ static ssize_t stats_show(struct class *class, struct class_attribute *attr,
432432
"reset",
433433
"shutdown"
434434
};
435-
436-
ssize_t sz = scnprintf(buf, PAGE_SIZE, "%d %s %d %lu\n", stats_version,
437-
state[server_conf.state], server_conf.tcp_port,
438-
server_conf.ipc_last_active / HZ);
439-
return sz;
435+
return sysfs_emit(buf, "%d %s %d %lu\n", stats_version,
436+
state[server_conf.state], server_conf.tcp_port,
437+
server_conf.ipc_last_active / HZ);
440438
}
441439

442440
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,
468466

469467
for (i = 0; i < ARRAY_SIZE(debug_type_strings); i++) {
470468
if ((ksmbd_debug_types >> i) & 1) {
471-
pos = scnprintf(buf + sz,
472-
PAGE_SIZE - sz,
473-
"[%s] ",
474-
debug_type_strings[i]);
469+
pos = sysfs_emit_at(buf, sz, "[%s] ", debug_type_strings[i]);
475470
} else {
476-
pos = scnprintf(buf + sz,
477-
PAGE_SIZE - sz,
478-
"%s ",
479-
debug_type_strings[i]);
471+
pos = sysfs_emit_at(buf, sz, "%s ", debug_type_strings[i]);
480472
}
481473
sz += pos;
482474
}
483-
sz += scnprintf(buf + sz, PAGE_SIZE - sz, "\n");
475+
sz += sysfs_emit_at(buf, sz, "\n");
484476
return sz;
485477
}
486478

0 commit comments

Comments
 (0)