[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240319063132.1588443-18-lizhijian@fujitsu.com>
Date: Tue, 19 Mar 2024 14:31:25 +0800
From: Li Zhijian <lizhijian@...itsu.com>
To: linux-kernel@...r.kernel.org
Cc: Li Zhijian <lizhijian@...itsu.com>,
"James E.J. Bottomley" <jejb@...ux.ibm.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
linux-scsi@...r.kernel.org
Subject: [PATCH v2 18/25] scsi: pmcraid: 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: "James E.J. Bottomley" <jejb@...ux.ibm.com>
CC: "Martin K. Petersen" <martin.petersen@...cle.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/pmcraid.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index e8bcc3a88732..56376d335b21 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -3538,7 +3538,7 @@ static ssize_t pmcraid_show_log_level(
struct Scsi_Host *shost = class_to_shost(dev);
struct pmcraid_instance *pinstance =
(struct pmcraid_instance *)shost->hostdata;
- return snprintf(buf, PAGE_SIZE, "%d\n", pinstance->current_log_level);
+ return sysfs_emit(buf, "%d\n", pinstance->current_log_level);
}
/**
@@ -3599,8 +3599,7 @@ static ssize_t pmcraid_show_drv_version(
char *buf
)
{
- return snprintf(buf, PAGE_SIZE, "version: %s\n",
- PMCRAID_DRIVER_VERSION);
+ return sysfs_emit(buf, "version: %s\n", PMCRAID_DRIVER_VERSION);
}
static struct device_attribute pmcraid_driver_version_attr = {
@@ -3632,9 +3631,8 @@ static ssize_t pmcraid_show_adapter_id(
u32 adapter_id = pci_dev_id(pinstance->pdev);
u32 aen_group = pmcraid_event_family.id;
- return snprintf(buf, PAGE_SIZE,
- "adapter id: %d\nminor: %d\naen group: %d\n",
- adapter_id, MINOR(pinstance->cdev.dev), aen_group);
+ return sysfs_emit(buf, "adapter id: %d\nminor: %d\naen group: %d\n",
+ adapter_id, MINOR(pinstance->cdev.dev), aen_group);
}
static struct device_attribute pmcraid_adapter_id_attr = {
--
2.29.2
Powered by blists - more mailing lists