Skip to contentSkip to conversation

memstick/mspro_block: use sysfs_emit() to instead of scnprintf()

PATCH Superseded [email protected] 2 participants 2 messages Dec 1, 2022 – Dec 7, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memstick/mspro_block: 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/memstick/core/mspro_block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memstick/core/mspro_block.c +1 -1
index 61cf75d4a01e..ae3a5dc00344 100644
@@ -356,7 +356,7 @@ static ssize_t mspro_block_attr_show_modelname(struct device *dev,
 						     struct mspro_sys_attr,
 						     dev_attr);
 
-	return scnprintf(buffer, PAGE_SIZE, "%s", (char *)s_attr->data);
+	return sysfs_emit(buffer, "%s\n", (char *)s_attr->data);
 }
 
 static ssize_t mspro_block_attr_show_mbr(struct device *dev,
Signature · 1 line
2.25.1
#1 lore raw
Quoted 6 lines · On Thu, 1 Dec 2022 at 12:50, <[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.

There are plenty of other conversions that can be done using sysfs_emit_at() in drivers/memstick/core/mspro_block.c. Would you mind doing that too, as part of the $subject patch?

Kind regards
Uffe

Quoted 21 lines
---
 drivers/memstick/core/mspro_block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memstick/core/mspro_block.c +1 -2
index 61cf75d4a01e..ae3a5dc00344 100644
@@ -356,7 +356,7 @@ static ssize_t mspro_block_attr_show_modelname(struct device *dev,
                                                     struct mspro_sys_attr,
                                                     dev_attr);
 
-       return scnprintf(buffer, PAGE_SIZE, "%s", (char *)s_attr->data);
+       return sysfs_emit(buffer, "%s\n", (char *)s_attr->data);
 }
 
 static ssize_t mspro_block_attr_show_mbr(struct device *dev,
--

2.25.1