Skip to contentSkip to conversation

mfd: use sysfs_emit() to instead of scnprintf()

PATCH Applied [email protected] 2 participants 2 messages Dec 2, 2022 – Jan 4, 2023 Multifunction devices (MFD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mfd: 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/mfd/kempld-core.c | 7 +++----
 drivers/mfd/lm3533-core.c | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)
drivers/mfd/kempld-core.c +3 -4
index bb26241c73bd..33c6cfe9fe42 100644
@@ -349,7 +349,7 @@ static ssize_t pld_version_show(struct device *dev,
 {
 	struct kempld_device_data *pld = dev_get_drvdata(dev);
 
-	return scnprintf(buf, PAGE_SIZE, "%s\n", pld->info.version);
+	return sysfs_emit(buf, "%s\n", pld->info.version);
 }
 
 static ssize_t pld_specification_show(struct device *dev,
@@ -357,8 +357,7 @@ static ssize_t pld_specification_show(struct device *dev,
 {
 	struct kempld_device_data *pld = dev_get_drvdata(dev);
 
-	return scnprintf(buf, PAGE_SIZE, "%d.%d\n", pld->info.spec_major,
-		       pld->info.spec_minor);
+	return sysfs_emit(buf, "%d.%d\n", pld->info.spec_major, pld->info.spec_minor);
 }
 
 static ssize_t pld_type_show(struct device *dev,
@@ -366,7 +365,7 @@ static ssize_t pld_type_show(struct device *dev,
 {
 	struct kempld_device_data *pld = dev_get_drvdata(dev);
 
-	return scnprintf(buf, PAGE_SIZE, "%s\n", kempld_get_type_string(pld));
+	return sysfs_emit(buf, "%s\n", kempld_get_type_string(pld));
 }
 
 static DEVICE_ATTR_RO(pld_version);
drivers/mfd/lm3533-core.c +1 -1
index be32ffc5af38..b353d93b0939 100644
@@ -286,7 +286,7 @@ static ssize_t show_output(struct device *dev,
 
 	val = (val & mask) >> shift;
 
-	return scnprintf(buf, PAGE_SIZE, "%u\n", val);
+	return sysfs_emit(buf, "%u\n", val);
 }
 
 static ssize_t store_output(struct device *dev,
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 11 lines · On Fri, 02 Dec 2022, [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/mfd/kempld-core.c | 7 +++----
 drivers/mfd/lm3533-core.c | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

Applied, thanks

Signature · 1 line
Lee Jones [李琼斯]