diff mbox series

[28/42] drivers/scsi/megaraid: Convert snprintf to sysfs_emit

Message ID 20240116045151.3940401-26-lizhijian@fujitsu.com
State Superseded
Headers show
Series Fix coccicheck warnings | expand

Commit Message

Zhijian Li (Fujitsu) Jan. 16, 2024, 4:51 a.m. UTC
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.

coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().

> ./drivers/scsi/megaraid/megaraid_sas_base.c:3336:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/megaraid/megaraid_sas_base.c:3382:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/megaraid/megaraid_sas_base.c:3389:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/megaraid/megaraid_sas_base.c:3399:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/megaraid/megaraid_sas_base.c:3409:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/megaraid/megaraid_sas_base.c:3419:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/megaraid/megaraid_sas_base.c:3473:8-16: WARNING: please use sysfs_emit

No functional change intended

CC: Kashyap Desai <kashyap.desai@broadcom.com>
CC: Sumit Saxena <sumit.saxena@broadcom.com>
CC: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
CC: Chandrakanth patil <chandrakanth.patil@broadcom.com>
CC: "James E.J. Bottomley" <jejb@linux.ibm.com>
CC: "Martin K. Petersen" <martin.petersen@oracle.com>
CC: megaraidlinux.pdl@broadcom.com
CC: linux-scsi@vger.kernel.org
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 3d4f13da1ae8..4e4414df1935 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -3333,7 +3333,7 @@  fw_crash_buffer_size_show(struct device *cdev,
 	struct megasas_instance *instance =
 		(struct megasas_instance *) shost->hostdata;
 
-	return snprintf(buf, PAGE_SIZE, "%ld\n", (unsigned long)
+	return sysfs_emit(buf, "%ld\n", (unsigned long)
 		((instance->fw_crash_buffer_size) * 1024 * 1024)/PAGE_SIZE);
 }
 
@@ -3379,14 +3379,14 @@  fw_crash_state_show(struct device *cdev,
 	struct megasas_instance *instance =
 		(struct megasas_instance *) shost->hostdata;
 
-	return snprintf(buf, PAGE_SIZE, "%d\n", instance->fw_crash_state);
+	return sysfs_emit(buf, "%d\n", instance->fw_crash_state);
 }
 
 static ssize_t
 page_size_show(struct device *cdev,
 	struct device_attribute *attr, char *buf)
 {
-	return snprintf(buf, PAGE_SIZE, "%ld\n", (unsigned long)PAGE_SIZE - 1);
+	return sysfs_emit(buf, "%ld\n", (unsigned long)PAGE_SIZE - 1);
 }
 
 static ssize_t
@@ -3396,7 +3396,7 @@  ldio_outstanding_show(struct device *cdev, struct device_attribute *attr,
 	struct Scsi_Host *shost = class_to_shost(cdev);
 	struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata;
 
-	return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&instance->ldio_outstanding));
+	return sysfs_emit(buf, "%d\n", atomic_read(&instance->ldio_outstanding));
 }
 
 static ssize_t
@@ -3406,7 +3406,7 @@  fw_cmds_outstanding_show(struct device *cdev,
 	struct Scsi_Host *shost = class_to_shost(cdev);
 	struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata;
 
-	return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&instance->fw_outstanding));
+	return sysfs_emit(buf, "%d\n", atomic_read(&instance->fw_outstanding));
 }
 
 static ssize_t
@@ -3416,7 +3416,7 @@  enable_sdev_max_qd_show(struct device *cdev,
 	struct Scsi_Host *shost = class_to_shost(cdev);
 	struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata;
 
-	return snprintf(buf, PAGE_SIZE, "%d\n", instance->enable_sdev_max_qd);
+	return sysfs_emit(buf, "%d\n", instance->enable_sdev_max_qd);
 }
 
 static ssize_t
@@ -3470,8 +3470,7 @@  raid_map_id_show(struct device *cdev, struct device_attribute *attr,
 	struct megasas_instance *instance =
 			(struct megasas_instance *)shost->hostdata;
 
-	return snprintf(buf, PAGE_SIZE, "%ld\n",
-			(unsigned long)instance->map_id);
+	return sysfs_emit(buf, "%ld\n", (unsigned long)instance->map_id);
 }
 
 static DEVICE_ATTR_RW(fw_crash_buffer);