Skip to contentSkip to conversation

s390/qeth: use sysfs_emit() to instead of scnprintf()

PATCH In review [email protected] 3 participants 3 messages Dec 5, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390/qeth: use sysfs_emit() to instead of scnprintf()

From: ye xingchen <[email protected]>

Follow the advice of the Documentation/filesystems/sysfs.rst and show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space.

---
 drivers/s390/net/qeth_l3_sys.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/net/qeth_l3_sys.c +2 -2
index 1082380b21f8..65eea667e469 100644
@@ -395,7 +395,7 @@ static ssize_t qeth_l3_dev_ipato_add_show(char *buf, struct qeth_card *card,
 	}
 	mutex_unlock(&card->ip_lock);
 
-	return str_len ? str_len : scnprintf(buf, PAGE_SIZE, "\n");
+	return str_len ? str_len : sysfs_emit(buf, "\n");
 }
 
 static ssize_t qeth_l3_dev_ipato_add4_show(struct device *dev,
@@ -614,7 +614,7 @@ static ssize_t qeth_l3_dev_ip_add_show(struct device *dev, char *buf,
 	}
 	mutex_unlock(&card->ip_lock);
 
-	return str_len ? str_len : scnprintf(buf, PAGE_SIZE, "\n");
+	return str_len ? str_len : sysfs_emit(buf, "\n");
 }
 
 static ssize_t qeth_l3_dev_vipa_add4_show(struct device *dev,
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 25 lines · On 05.12.22 04:52, [email protected] wrote:

From: ye xingchen <[email protected]>

Follow the advice of the Documentation/filesystems/sysfs.rst and show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space.

---
 drivers/s390/net/qeth_l3_sys.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/net/qeth_l3_sys.c +1 -1
index 1082380b21f8..65eea667e469 100644
@@ -395,7 +395,7 @@ static ssize_t qeth_l3_dev_ipato_add_show(char *buf, struct qeth_card *card,
 	}
 	mutex_unlock(&card->ip_lock);
 
-	return str_len ? str_len : scnprintf(buf, PAGE_SIZE, "\n");
+	return str_len ? str_len : sysfs_emit(buf, "\n");
 }
 
 static ssize_t qeth_l3_dev_ipato_add4_show(struct device *dev,

drivers/s390/net/qeth_l3_sys.c static ssize_t qeth_l3_dev_ip_add_show(struct device *dev, char *buf, · line 620

Quoted 8 lines
drivers/s390/net/qeth_l3_sys.c +1 -1
@@ -614,7 +614,7 @@ static ssize_t qeth_l3_dev_ip_add_show(struct device *dev, char *buf,
 	}
 	mutex_unlock(&card->ip_lock);
 
-	return str_len ? str_len : scnprintf(buf, PAGE_SIZE, "\n");
+	return str_len ? str_len : sysfs_emit(buf, "\n");
 }
 
 static ssize_t qeth_l3_dev_vipa_add4_show(struct device *dev,

There are more instances of scnprintf in s390/net that can be replaced by sysfs_emit. We are already working on that.

But thanks for improving those two.

#2 lore raw
Quoted 31 lines · Alexandra Winter
Quoted 28 lines · On 05.12.22 04:52, [email protected] wrote:

From: ye xingchen <[email protected]>

Follow the advice of the Documentation/filesystems/sysfs.rst and show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space.

---
 drivers/s390/net/qeth_l3_sys.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/net/qeth_l3_sys.c +1 -1
index 1082380b21f8..65eea667e469 100644
@@ -395,7 +395,7 @@ static ssize_t qeth_l3_dev_ipato_add_show(char *buf, struct qeth_card *card,
 	}
 	mutex_unlock(&card->ip_lock);
 
-	return str_len ? str_len : scnprintf(buf, PAGE_SIZE, "\n");
+	return str_len ? str_len : sysfs_emit(buf, "\n");
 }
 
 static ssize_t qeth_l3_dev_ipato_add4_show(struct device *dev,
@@ -614,7 +614,7 @@ static ssize_t qeth_l3_dev_ip_add_show(struct device *dev, char *buf,
 	}
 	mutex_unlock(&card->ip_lock);
 
Quoted 7 lines

drivers/s390/net/qeth_l3_sys.c static ssize_t qeth_l3_dev_ip_add_show(struct device *dev, char *buf, · line 620

Quoted 5 lines
drivers/s390/net/qeth_l3_sys.c +1 -1
-	return str_len ? str_len : scnprintf(buf, PAGE_SIZE, "\n");
+	return str_len ? str_len : sysfs_emit(buf, "\n");
 }
 
 static ssize_t qeth_l3_dev_vipa_add4_show(struct device *dev,

There are more instances of scnprintf in s390/net that can be replaced by sysfs_emit. We are already working on that.

It seems this particular fix misses scnprintf() to sysfs_emit() conversion within same very functions just few lines above.

Quoted 2 lines

But thanks for improving those two.