Commit 1ad717c9 authored by Li Zhijian's avatar Li Zhijian Committed by Martin K. Petersen

scsi: fnic: Convert snprintf() to sysfs_emit()

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/fnic/fnic_attrs.c:17:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/fnic/fnic_attrs.c:23:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/fnic/fnic_attrs.c:31:8-16: WARNING: please use sysfs_emit

No functional change intended

CC: Satish Kharat <satishkh@cisco.com>
CC: Sesidhar Baddela <sebaddel@cisco.com>
CC: Karan Tilak Kumar <kartilak@cisco.com>
CC: James E.J. Bottomley <jejb@linux.ibm.com>
CC: Martin K. Petersen <martin.petersen@oracle.com>
CC: linux-scsi@vger.kernel.org
Signed-off-by: default avatarLi Zhijian <lizhijian@fujitsu.com>
Link: https://lore.kernel.org/r/20240116045151.3940401-20-lizhijian@fujitsu.comReviewed-by: default avatarKaran Tilak Kumar <kartilak@cisco.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent bc978cc1
...@@ -14,13 +14,13 @@ static ssize_t fnic_show_state(struct device *dev, ...@@ -14,13 +14,13 @@ static ssize_t fnic_show_state(struct device *dev,
struct fc_lport *lp = shost_priv(class_to_shost(dev)); struct fc_lport *lp = shost_priv(class_to_shost(dev));
struct fnic *fnic = lport_priv(lp); 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, static ssize_t fnic_show_drv_version(struct device *dev,
struct device_attribute *attr, char *buf) 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, static ssize_t fnic_show_link_state(struct device *dev,
...@@ -28,8 +28,7 @@ static ssize_t fnic_show_link_state(struct device *dev, ...@@ -28,8 +28,7 @@ static ssize_t fnic_show_link_state(struct device *dev,
{ {
struct fc_lport *lp = shost_priv(class_to_shost(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");
? "Link Up" : "Link Down");
} }
static DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL); static DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment