]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/cio/chp: Switch over to sysfs_emit()
authorMete Durlu <meted@linux.ibm.com>
Wed, 23 Oct 2024 12:11:02 +0000 (14:11 +0200)
committerHeiko Carstens <hca@linux.ibm.com>
Fri, 25 Oct 2024 14:03:24 +0000 (16:03 +0200)
Per Documentation/filesystems/sysfs.rst, sysfs_emit() is preferred for
presenting attributes to user space in sysfs. Convert the left-over uses
in the cio/chp code.

Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Tested-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Acked-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
drivers/s390/cio/chp.c

index a07bbecba61cd491826f67fed8f88a9e1b27520e..8f9aa31bd1a1527164cd02973f11ebd10324a56d 100644 (file)
@@ -230,7 +230,7 @@ static ssize_t chp_status_show(struct device *dev,
        status = chp->state;
        mutex_unlock(&chp->lock);
 
-       return status ? sprintf(buf, "online\n") : sprintf(buf, "offline\n");
+       return status ? sysfs_emit(buf, "online\n") : sysfs_emit(buf, "offline\n");
 }
 
 static ssize_t chp_status_write(struct device *dev,
@@ -311,7 +311,7 @@ static ssize_t chp_type_show(struct device *dev, struct device_attribute *attr,
        mutex_lock(&chp->lock);
        type = chp->desc.desc;
        mutex_unlock(&chp->lock);
-       return sprintf(buf, "%x\n", type);
+       return sysfs_emit(buf, "%x\n", type);
 }
 
 static DEVICE_ATTR(type, 0444, chp_type_show, NULL);
@@ -324,8 +324,8 @@ static ssize_t chp_cmg_show(struct device *dev, struct device_attribute *attr,
        if (!chp)
                return 0;
        if (chp->cmg == -1) /* channel measurements not available */
-               return sprintf(buf, "unknown\n");
-       return sprintf(buf, "%d\n", chp->cmg);
+               return sysfs_emit(buf, "unknown\n");
+       return sysfs_emit(buf, "%d\n", chp->cmg);
 }
 
 static DEVICE_ATTR(cmg, 0444, chp_cmg_show, NULL);
@@ -338,8 +338,8 @@ static ssize_t chp_shared_show(struct device *dev,
        if (!chp)
                return 0;
        if (chp->shared == -1) /* channel measurements not available */
-               return sprintf(buf, "unknown\n");
-       return sprintf(buf, "%x\n", chp->shared);
+               return sysfs_emit(buf, "unknown\n");
+       return sysfs_emit(buf, "%x\n", chp->shared);
 }
 
 static DEVICE_ATTR(shared, 0444, chp_shared_show, NULL);
@@ -352,7 +352,7 @@ static ssize_t chp_chid_show(struct device *dev, struct device_attribute *attr,
 
        mutex_lock(&chp->lock);
        if (chp->desc_fmt1.flags & 0x10)
-               rc = sprintf(buf, "%04x\n", chp->desc_fmt1.chid);
+               rc = sysfs_emit(buf, "%04x\n", chp->desc_fmt1.chid);
        else
                rc = 0;
        mutex_unlock(&chp->lock);
@@ -369,7 +369,7 @@ static ssize_t chp_chid_external_show(struct device *dev,
 
        mutex_lock(&chp->lock);
        if (chp->desc_fmt1.flags & 0x10)
-               rc = sprintf(buf, "%x\n", chp->desc_fmt1.flags & 0x8 ? 1 : 0);
+               rc = sysfs_emit(buf, "%x\n", chp->desc_fmt1.flags & 0x8 ? 1 : 0);
        else
                rc = 0;
        mutex_unlock(&chp->lock);
@@ -385,7 +385,7 @@ static ssize_t chp_esc_show(struct device *dev,
        ssize_t rc;
 
        mutex_lock(&chp->lock);
-       rc = sprintf(buf, "%x\n", chp->desc_fmt1.esc);
+       rc = sysfs_emit(buf, "%x\n", chp->desc_fmt1.esc);
        mutex_unlock(&chp->lock);
 
        return rc;