Skip to content

Commit e82fff0

Browse files
ankitchauhan2065maddy-kerneldev
authored andcommitted
misc: ocxl: Replace scnprintf() with sysfs_emit() in sysfs show functions
Replace scnprintf() with sysfs_emit() in sysfs show functions. These helpers are preferred in sysfs callbacks because they automatically handle buffer size and improve safety and readability. Signed-off-by: Ankit Chauhan <[email protected]> Acked-by: Andrew Donnellan <[email protected]> Signed-off-by: Madhavan Srinivasan <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent bde5b1a commit e82fff0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/misc/ocxl/sysfs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static ssize_t global_mmio_size_show(struct device *device,
1616
{
1717
struct ocxl_afu *afu = to_afu(device);
1818

19-
return scnprintf(buf, PAGE_SIZE, "%d\n",
19+
return sysfs_emit(buf, "%d\n",
2020
afu->config.global_mmio_size);
2121
}
2222

@@ -26,7 +26,7 @@ static ssize_t pp_mmio_size_show(struct device *device,
2626
{
2727
struct ocxl_afu *afu = to_afu(device);
2828

29-
return scnprintf(buf, PAGE_SIZE, "%d\n",
29+
return sysfs_emit(buf, "%d\n",
3030
afu->config.pp_mmio_stride);
3131
}
3232

@@ -36,7 +36,7 @@ static ssize_t afu_version_show(struct device *device,
3636
{
3737
struct ocxl_afu *afu = to_afu(device);
3838

39-
return scnprintf(buf, PAGE_SIZE, "%hhu:%hhu\n",
39+
return sysfs_emit(buf, "%hhu:%hhu\n",
4040
afu->config.version_major,
4141
afu->config.version_minor);
4242
}
@@ -47,7 +47,7 @@ static ssize_t contexts_show(struct device *device,
4747
{
4848
struct ocxl_afu *afu = to_afu(device);
4949

50-
return scnprintf(buf, PAGE_SIZE, "%d/%d\n",
50+
return sysfs_emit(buf, "%d/%d\n",
5151
afu->pasid_count, afu->pasid_max);
5252
}
5353

@@ -61,9 +61,9 @@ static ssize_t reload_on_reset_show(struct device *device,
6161
int val;
6262

6363
if (ocxl_config_get_reset_reload(pci_dev, &val))
64-
return scnprintf(buf, PAGE_SIZE, "unavailable\n");
64+
return sysfs_emit(buf, "unavailable\n");
6565

66-
return scnprintf(buf, PAGE_SIZE, "%d\n", val);
66+
return sysfs_emit(buf, "%d\n", val);
6767
}
6868

6969
static ssize_t reload_on_reset_store(struct device *device,

0 commit comments

Comments
 (0)