Skip to contentSkip to conversation

fpga: bridge: Use sysfs_emit() instead of sprintf()

PATCH In review Dinh Nguyen 2 participants 3 messages Jan 17 – Mar 2 FPGA manager framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fpga: bridge: Use sysfs_emit() instead of sprintf()

According to Documentation/filesystems/sysfs.rst, show() functions should use sysfs_emit() when formatting the value to be returned to user space.

---
 drivers/fpga/fpga-bridge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/fpga-bridge.c +1 -1
index 8ef395b49bf8..d0d28d5f6112 100644
@@ -290,7 +290,7 @@ static ssize_t name_show(struct device *dev,
 {
 	struct fpga_bridge *bridge = to_fpga_bridge(dev);
 
-	return sprintf(buf, "%s\n", bridge->name);
+	return sysfs_emit(buf, "%s\n", bridge->name);
 }
 
 static ssize_t state_show(struct device *dev,
Signature · 1 line
2.42.0.411.g813d9a9188
#1 lore raw
Quoted 2 lines · Dinh Nguyen

According to Documentation/filesystems/sysfs.rst, show() functions should use sysfs_emit() when formatting the value to be returned to user

The doc says "New implementations ... should only use ...". The existing code is OK, the patch is also OK, but sorry I expect we don't churn code just for doing it. We could also append these trivial changes along with patchsets that make real improvements.

Thanks,
Yilun

Reviewed-by
#2 lore raw
Quoted 8 lines · Xu Yilun
Quoted 2 lines · Dinh Nguyen

According to Documentation/filesystems/sysfs.rst, show() functions should use sysfs_emit() when formatting the value to be returned to user

The doc says "New implementations ... should only use ...". The existing code is OK, the patch is also OK, but sorry I expect we don't churn code just for doing it. We could also append these trivial changes along with patchsets that make real improvements.

I'm sorry. I changed my mind and would like to apply this patch. This change solves the inconsistent usage of sprintf() & sysfs_emit() in the same file.

Quoted 4 lines

Thanks,
Yilun