]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
misc: ocxl: Replace scnprintf() with sysfs_emit() in sysfs show functions
authorAnkit Chauhan <ankitchauhan2065@gmail.com>
Fri, 20 Jun 2025 02:47:05 +0000 (08:17 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Jun 2025 15:45:47 +0000 (16:45 +0100)
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 <ankitchauhan2065@gmail.com>
Acked-by: Andrew Donnellan <ajd@linux.ibm.com>
Link: https://lore.kernel.org/r/20250620024705.11321-1-ankitchauhan2065@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/ocxl/sysfs.c

index e849641687a005fec5eb7a6b2e96bc0e9d04dc05..f194c159a778ae3d7edeef3dea3f78d7405412e3 100644 (file)
@@ -16,7 +16,7 @@ static ssize_t global_mmio_size_show(struct device *device,
 {
        struct ocxl_afu *afu = to_afu(device);
 
-       return scnprintf(buf, PAGE_SIZE, "%d\n",
+       return sysfs_emit(buf, "%d\n",
                        afu->config.global_mmio_size);
 }
 
@@ -26,7 +26,7 @@ static ssize_t pp_mmio_size_show(struct device *device,
 {
        struct ocxl_afu *afu = to_afu(device);
 
-       return scnprintf(buf, PAGE_SIZE, "%d\n",
+       return sysfs_emit(buf, "%d\n",
                        afu->config.pp_mmio_stride);
 }
 
@@ -36,7 +36,7 @@ static ssize_t afu_version_show(struct device *device,
 {
        struct ocxl_afu *afu = to_afu(device);
 
-       return scnprintf(buf, PAGE_SIZE, "%hhu:%hhu\n",
+       return sysfs_emit(buf, "%hhu:%hhu\n",
                        afu->config.version_major,
                        afu->config.version_minor);
 }
@@ -47,7 +47,7 @@ static ssize_t contexts_show(struct device *device,
 {
        struct ocxl_afu *afu = to_afu(device);
 
-       return scnprintf(buf, PAGE_SIZE, "%d/%d\n",
+       return sysfs_emit(buf, "%d/%d\n",
                        afu->pasid_count, afu->pasid_max);
 }
 
@@ -61,9 +61,9 @@ static ssize_t reload_on_reset_show(struct device *device,
        int val;
 
        if (ocxl_config_get_reset_reload(pci_dev, &val))
-               return scnprintf(buf, PAGE_SIZE, "unavailable\n");
+               return sysfs_emit(buf, "unavailable\n");
 
-       return scnprintf(buf, PAGE_SIZE, "%d\n", val);
+       return sysfs_emit(buf, "%d\n", val);
 }
 
 static ssize_t reload_on_reset_store(struct device *device,