Commit aaebea95 authored by Li Zhijian's avatar Li Zhijian Committed by Alexander Gordeev

s390/cio: convert sprintf()/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().

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: Vineeth Vijayan <vneethv@linux.ibm.com>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: default avatarLi Zhijian <lizhijian@fujitsu.com>
Link: https://lore.kernel.org/r/20240314095209.1325229-1-lizhijian@fujitsu.comSigned-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
parent b3840c8b
...@@ -309,7 +309,7 @@ static ssize_t type_show(struct device *dev, struct device_attribute *attr, ...@@ -309,7 +309,7 @@ static ssize_t type_show(struct device *dev, struct device_attribute *attr,
{ {
struct subchannel *sch = to_subchannel(dev); struct subchannel *sch = to_subchannel(dev);
return sprintf(buf, "%01x\n", sch->st); return sysfs_emit(buf, "%01x\n", sch->st);
} }
static DEVICE_ATTR_RO(type); static DEVICE_ATTR_RO(type);
...@@ -319,7 +319,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, ...@@ -319,7 +319,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
{ {
struct subchannel *sch = to_subchannel(dev); struct subchannel *sch = to_subchannel(dev);
return sprintf(buf, "css:t%01X\n", sch->st); return sysfs_emit(buf, "css:t%01X\n", sch->st);
} }
static DEVICE_ATTR_RO(modalias); static DEVICE_ATTR_RO(modalias);
...@@ -345,7 +345,7 @@ static ssize_t driver_override_show(struct device *dev, ...@@ -345,7 +345,7 @@ static ssize_t driver_override_show(struct device *dev,
ssize_t len; ssize_t len;
device_lock(dev); device_lock(dev);
len = snprintf(buf, PAGE_SIZE, "%s\n", sch->driver_override); len = sysfs_emit(buf, "%s\n", sch->driver_override);
device_unlock(dev); device_unlock(dev);
return len; return len;
} }
...@@ -396,8 +396,8 @@ static ssize_t pimpampom_show(struct device *dev, ...@@ -396,8 +396,8 @@ static ssize_t pimpampom_show(struct device *dev,
struct subchannel *sch = to_subchannel(dev); struct subchannel *sch = to_subchannel(dev);
struct pmcw *pmcw = &sch->schib.pmcw; struct pmcw *pmcw = &sch->schib.pmcw;
return sprintf(buf, "%02x %02x %02x\n", return sysfs_emit(buf, "%02x %02x %02x\n",
pmcw->pim, pmcw->pam, pmcw->pom); pmcw->pim, pmcw->pam, pmcw->pom);
} }
static DEVICE_ATTR_RO(pimpampom); static DEVICE_ATTR_RO(pimpampom);
...@@ -881,7 +881,7 @@ static ssize_t real_cssid_show(struct device *dev, struct device_attribute *a, ...@@ -881,7 +881,7 @@ static ssize_t real_cssid_show(struct device *dev, struct device_attribute *a,
if (!css->id_valid) if (!css->id_valid)
return -EINVAL; return -EINVAL;
return sprintf(buf, "%x\n", css->cssid); return sysfs_emit(buf, "%x\n", css->cssid);
} }
static DEVICE_ATTR_RO(real_cssid); static DEVICE_ATTR_RO(real_cssid);
...@@ -904,7 +904,7 @@ static ssize_t cm_enable_show(struct device *dev, struct device_attribute *a, ...@@ -904,7 +904,7 @@ static ssize_t cm_enable_show(struct device *dev, struct device_attribute *a,
int ret; int ret;
mutex_lock(&css->mutex); mutex_lock(&css->mutex);
ret = sprintf(buf, "%x\n", css->cm_enabled); ret = sysfs_emit(buf, "%x\n", css->cm_enabled);
mutex_unlock(&css->mutex); mutex_unlock(&css->mutex);
return ret; return ret;
} }
......
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