ksmbd: Convert to use sysfs_emit()/sysfs_emit_at() APIs
Subsystems (2)
PATCH 1/1 ksmbd: Convert to use sysfs_emit()/sysfs_emit_at() APIs
From: ye xingchen <[email protected]>
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.
--- fs/ksmbd/server.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
fs/ksmbd/server.c +6 -14
@@ -432,11 +432,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,
@@ -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++) {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; }
Signature · 1 line
2.25.1
2022-12-07 10:29 GMT+09:00, [email protected] <[email protected]>:
Quoted 7 lines
From: ye xingchen <[email protected]>
Follow the advice of the
Documentation/filesystems/sysfs.rstandshow()should only usesysfs_emit()orsysfs_emit_at()when formatting the value to be returned to user space.Signed-off-by ye xingchen <[email protected]>
Thanks!
Quoted 7 lines · On (22/12/07 09:29), [email protected] wrote:
From: ye xingchen <[email protected]>
Follow the advice of the
Documentation/filesystems/sysfs.rstandshow()should only usesysfs_emit()orsysfs_emit_at()when formatting the value to be returned to user space.Signed-off-by ye xingchen <[email protected]>