2022-05-08 19:19:03

by Jiabing Wan

[permalink] [raw]
Subject: [PATCH] scsi: mpi3mr: Replace snprintf with sysfs_emit in adp_state_show

Fix following coccicheck warning:
./drivers/scsi/mpi3mr/mpi3mr_app.c:1588:8-16: WARNING: use scnprintf or sprintf

Use sysfs_emit instead of snprintf and fix some comments.

Signed-off-by: Wan Jiabing <[email protected]>
---
drivers/scsi/mpi3mr/mpi3mr_app.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c
index 73bb7992d5a8..86a7206548e4 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_app.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_app.c
@@ -1559,12 +1559,12 @@ void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc)
}

/**
- * adapter_state_show - SysFS callback for adapter state show
+ * adp_state_show - SysFS callback for adapter state show
* @dev: class device
* @attr: Device attributes
* @buf: Buffer to copy
*
- * Return: snprintf() return after copying adapter state
+ * Return: sysfs_emit() return after copying adapter state
*/
static ssize_t
adp_state_show(struct device *dev, struct device_attribute *attr,
@@ -1585,7 +1585,7 @@ adp_state_show(struct device *dev, struct device_attribute *attr,
else
adp_state = MPI3MR_BSG_ADPSTATE_OPERATIONAL;

- return snprintf(buf, PAGE_SIZE, "%u\n", adp_state);
+ return sysfs_emit(buf, "%u\n", adp_state);
}

static DEVICE_ATTR_RO(adp_state);
--
2.36.0