[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240319063132.1588443-7-lizhijian@fujitsu.com>
Date: Tue, 19 Mar 2024 14:31:14 +0800
From: Li Zhijian <lizhijian@...itsu.com>
To: linux-kernel@...r.kernel.org
Cc: Li Zhijian <lizhijian@...itsu.com>,
Kashyap Desai <kashyap.desai@...adcom.com>,
Sumit Saxena <sumit.saxena@...adcom.com>,
Shivasharan S <shivasharan.srikanteshwara@...adcom.com>,
Chandrakanth patil <chandrakanth.patil@...adcom.com>,
"James E.J. Bottomley" <jejb@...ux.ibm.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
megaraidlinux.pdl@...adcom.com,
linux-scsi@...r.kernel.org
Subject: [PATCH v2 07/25] scsi: megaraid: Convert sprintf() family to sysfs_emit() family
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().
sprintf() and scnprintf() will be converted as well if they have.
Generally, this patch is generated by
make coccicheck M=<path/to/file> MODE=patch \
COCCI=scripts/coccinelle/api/device_attr_show.cocci
No functional change intended
CC: Kashyap Desai <kashyap.desai@...adcom.com>
CC: Sumit Saxena <sumit.saxena@...adcom.com>
CC: Shivasharan S <shivasharan.srikanteshwara@...adcom.com>
CC: Chandrakanth patil <chandrakanth.patil@...adcom.com>
CC: "James E.J. Bottomley" <jejb@...ux.ibm.com>
CC: "Martin K. Petersen" <martin.petersen@...cle.com>
CC: megaraidlinux.pdl@...adcom.com
CC: linux-scsi@...r.kernel.org
Signed-off-by: Li Zhijian <lizhijian@...itsu.com>
---
This is a part of the work "Fix coccicheck device_attr_show warnings"[1]
Split them per subsystem so that the maintainer can review it easily
[1] https://lore.kernel.org/lkml/20240116041129.3937800-1-lizhijian@fujitsu.com/
---
drivers/scsi/megaraid/megaraid_sas_base.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 3d4f13da1ae8..07df615f43af 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -3333,8 +3333,8 @@ 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)
- ((instance->fw_crash_buffer_size) * 1024 * 1024)/PAGE_SIZE);
+ return sysfs_emit(buf, "%ld\n", (unsigned long)
+ ((instance->fw_crash_buffer_size) * 1024 * 1024) / PAGE_SIZE);
}
static ssize_t
@@ -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,8 @@ 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 +3407,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 +3417,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 +3471,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);
--
2.29.2
Powered by blists - more mailing lists