* [PATCH] scsi: fnic: Use sysfs_emit in show function callsbacks
@ 2022-12-25 8:52 Deepak R Varma
0 siblings, 0 replies; only message in thread
From: Deepak R Varma @ 2022-12-25 8:52 UTC (permalink / raw)
To: Satish Kharat, Sesidhar Baddela, Karan Tilak Kumar,
James E.J. Bottomley, Martin K. Petersen, linux-scsi,
linux-kernel
Cc: Saurabh Singh Sengar, Praveen Kumar, Deepak R Varma
According to Documentation/filesystems/sysfs.rst, the show() callback
function of kobject attributes should strictly use sysfs_emit() instead
of sprintf() family functions. So, make this change.
Issue identified using the coccinelle device_attr_show.cocci script.
Signed-off-by: Deepak R Varma <drv@mailo.com>
---
drivers/scsi/fnic/fnic_attrs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/fnic/fnic_attrs.c b/drivers/scsi/fnic/fnic_attrs.c
index a61e0c5e6506..1798d1e6318f 100644
--- a/drivers/scsi/fnic/fnic_attrs.c
+++ b/drivers/scsi/fnic/fnic_attrs.c
@@ -14,13 +14,13 @@ static ssize_t fnic_show_state(struct device *dev,
struct fc_lport *lp = shost_priv(class_to_shost(dev));
struct fnic *fnic = lport_priv(lp);
- return snprintf(buf, PAGE_SIZE, "%s\n", fnic_state_str[fnic->state]);
+ return sysfs_emit(buf, "%s\n", fnic_state_str[fnic->state]);
}
static ssize_t fnic_show_drv_version(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION);
+ return sysfs_emit(buf, "%s\n", DRV_VERSION);
}
static ssize_t fnic_show_link_state(struct device *dev,
@@ -28,7 +28,7 @@ static ssize_t fnic_show_link_state(struct device *dev,
{
struct fc_lport *lp = shost_priv(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%s\n", (lp->link_up)
+ return sysfs_emit(buf, "%s\n", (lp->link_up)
? "Link Up" : "Link Down");
}
--
2.34.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-12-25 8:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-25 8:52 [PATCH] scsi: fnic: Use sysfs_emit in show function callsbacks Deepak R Varma
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox