Skip to contentSkip to conversation

Replace the use of scnprintf() with sysfs_emit_at() in several show functions to format the output into the sysfs buffer.

PATCH In review herculoxz 2 participants 2 messages Jun 29, 2025 – Jul 1, 2025 Men chameleon bus (mcb)

lore
Share & tools
lore

herculoxz

author
#0 lore raw

PATCH 1/1 Replace the use of scnprintf() with sysfs_emit_at() in several show functions to format the output into the sysfs buffer.

This change improves clarity and ensures proper bounds checking in line with the preferred sysfs_emit() API usage for sysfs 'show' functions. The PAGE_SIZE check is now handled internally by the helper.

No functional change intended.

---
 drivers/mcb/mcb-core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mcb/mcb-core.c +4 -4
index 9b8c40a6459a..c1367223e71a 100644
@@ -107,7 +107,7 @@ static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
 {
 	struct mcb_bus *bus = to_mcb_bus(dev);
 
-	return scnprintf(buf, PAGE_SIZE, "%d\n", bus->revision);
+	return sysfs_emit(buf, "%d\n", bus->revision);
 }
 static DEVICE_ATTR_RO(revision);
 
@@ -116,7 +116,7 @@ static ssize_t model_show(struct device *dev, struct device_attribute *attr,
 {
 	struct mcb_bus *bus = to_mcb_bus(dev);
 
-	return scnprintf(buf, PAGE_SIZE, "%c\n", bus->model);
+	return sysfs_emit(buf, "%c\n", bus->model);
 }
 static DEVICE_ATTR_RO(model);
 
@@ -125,7 +125,7 @@ static ssize_t minor_show(struct device *dev, struct device_attribute *attr,
 {
 	struct mcb_bus *bus = to_mcb_bus(dev);
 
-	return scnprintf(buf, PAGE_SIZE, "%d\n", bus->minor);
+	return sysfs_emit(buf, "%d\n", bus->minor);
 }
 static DEVICE_ATTR_RO(minor);
 
@@ -134,7 +134,7 @@ static ssize_t name_show(struct device *dev, struct device_attribute *attr,
 {
 	struct mcb_bus *bus = to_mcb_bus(dev);
 
-	return scnprintf(buf, PAGE_SIZE, "%s\n", bus->name);
+	return sysfs_emit(buf, "%s\n", bus->name);
 }
 static DEVICE_ATTR_RO(name);
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · herculoxz

This change improves clarity and ensures proper bounds checking in line with the preferred sysfs_emit() API usage for sysfs 'show' functions. The PAGE_SIZE check is now handled internally by the helper.

Can you please a) add an 'mcb:' prefix to the subject and b) make it fit into ~75 chars?

Code wise it looks ok: