Skip to content

Commit d439311

Browse files
TomAi0jwrdegoede
authored andcommitted
platform/x86: uv_sysfs: use sysfs_emit() instead of sprintf()
Follow the advice in Documentation/filesystems/sysfs.rst: show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. Signed-off-by: Ai Chao <aichao@kylinos.cn> Link: https://lore.kernel.org/r/20240319070038.309683-1-aichao@kylinos.cn Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent 415c33d commit d439311

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/platform/x86/uv_sysfs.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,22 +129,22 @@ static ssize_t hub_location_show(struct uv_bios_hub_info *hub_info, char *buf)
129129

130130
static ssize_t hub_partition_show(struct uv_bios_hub_info *hub_info, char *buf)
131131
{
132-
return sprintf(buf, "%d\n", hub_info->f.fields.this_part);
132+
return sysfs_emit(buf, "%d\n", hub_info->f.fields.this_part);
133133
}
134134

135135
static ssize_t hub_shared_show(struct uv_bios_hub_info *hub_info, char *buf)
136136
{
137-
return sprintf(buf, "%d\n", hub_info->f.fields.is_shared);
137+
return sysfs_emit(buf, "%d\n", hub_info->f.fields.is_shared);
138138
}
139139
static ssize_t hub_nasid_show(struct uv_bios_hub_info *hub_info, char *buf)
140140
{
141141
int cnode = get_obj_to_cnode(hub_info->id);
142142

143-
return sprintf(buf, "%d\n", ordinal_to_nasid(cnode));
143+
return sysfs_emit(buf, "%d\n", ordinal_to_nasid(cnode));
144144
}
145145
static ssize_t hub_cnode_show(struct uv_bios_hub_info *hub_info, char *buf)
146146
{
147-
return sprintf(buf, "%d\n", get_obj_to_cnode(hub_info->id));
147+
return sysfs_emit(buf, "%d\n", get_obj_to_cnode(hub_info->id));
148148
}
149149

150150
struct hub_sysfs_entry {
@@ -304,12 +304,12 @@ struct uv_port {
304304

305305
static ssize_t uv_port_conn_hub_show(struct uv_bios_port_info *port, char *buf)
306306
{
307-
return sprintf(buf, "%d\n", port->conn_id);
307+
return sysfs_emit(buf, "%d\n", port->conn_id);
308308
}
309309

310310
static ssize_t uv_port_conn_port_show(struct uv_bios_port_info *port, char *buf)
311311
{
312-
return sprintf(buf, "%d\n", port->conn_port);
312+
return sysfs_emit(buf, "%d\n", port->conn_port);
313313
}
314314

315315
struct uv_port_sysfs_entry {
@@ -470,7 +470,7 @@ static ssize_t uv_pci_location_show(struct uv_pci_top_obj *top_obj, char *buf)
470470

471471
static ssize_t uv_pci_iio_stack_show(struct uv_pci_top_obj *top_obj, char *buf)
472472
{
473-
return sprintf(buf, "%d\n", top_obj->iio_stack);
473+
return sysfs_emit(buf, "%d\n", top_obj->iio_stack);
474474
}
475475

476476
static ssize_t uv_pci_ppb_addr_show(struct uv_pci_top_obj *top_obj, char *buf)
@@ -480,7 +480,7 @@ static ssize_t uv_pci_ppb_addr_show(struct uv_pci_top_obj *top_obj, char *buf)
480480

481481
static ssize_t uv_pci_slot_show(struct uv_pci_top_obj *top_obj, char *buf)
482482
{
483-
return sprintf(buf, "%d\n", top_obj->slot);
483+
return sysfs_emit(buf, "%d\n", top_obj->slot);
484484
}
485485

486486
struct uv_pci_top_sysfs_entry {
@@ -725,13 +725,13 @@ static void pci_topology_exit(void)
725725
static ssize_t partition_id_show(struct kobject *kobj,
726726
struct kobj_attribute *attr, char *buf)
727727
{
728-
return sprintf(buf, "%ld\n", sn_partition_id);
728+
return sysfs_emit(buf, "%ld\n", sn_partition_id);
729729
}
730730

731731
static ssize_t coherence_id_show(struct kobject *kobj,
732732
struct kobj_attribute *attr, char *buf)
733733
{
734-
return sprintf(buf, "%ld\n", sn_coherency_id);
734+
return sysfs_emit(buf, "%ld\n", sn_coherency_id);
735735
}
736736

737737
static ssize_t uv_type_show(struct kobject *kobj,

0 commit comments

Comments
 (0)