Skip to contentSkip to conversation

docs: filesystems: sysfs: Recommend sysfs_emit() for new code only

PATCH Applied Bart Van Assche 4 participants 4 messages Jul 24, 2025 – Aug 11, 2025 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 docs: filesystems: sysfs: Recommend sysfs_emit() for new code only

The advantages of converting existing sysfs show() methods to sysfs_emit() and sysfs_emit_at() do not outweigh the risk of introducing bugs. Hence recommend sysfs_emit() and sysfs_emit_at() only for new implementations of show() methods.

Cc Greg Kroah-Hartman <[email protected]>
Cc James Bottomley <[email protected]>
Cc Martin K. Petersen <[email protected]>
---
 Documentation/filesystems/sysfs.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/filesystems/sysfs.rst +2 -2
index c32993bc83c7..624e4f51212e 100644
@@ -243,8 +243,8 @@ Other notes:
 - show() methods should return the number of bytes printed into the
   buffer.
 
-- show() should only use sysfs_emit() or sysfs_emit_at() when formatting
-  the value to be returned to user space.
+- New implementations of show() methods should only use sysfs_emit() or
+  sysfs_emit_at() when formatting the value to be returned to user space.
 
 - store() should return the number of bytes used from the buffer. If the
   entire buffer has been used, just return the count argument.
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Bart Van Assche

The advantages of converting existing sysfs show() methods to sysfs_emit() and sysfs_emit_at() do not outweigh the risk of introducing bugs. Hence recommend sysfs_emit() and sysfs_emit_at() only for new implementations of show() methods.

Quoted 7 lines
Cc Greg Kroah-Hartman <[email protected]>
Cc James Bottomley <[email protected]>
Cc Martin K. Petersen <[email protected]>
---
 Documentation/filesystems/sysfs.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by on v1 1/1
#2 lore raw
In reply to Bart Van Assche

Hi Bart!

Quoted 2 lines

-- show() should only use sysfs_emit() or sysfs_emit_at() when formatting

With my standards hat on: That's a "should", not a "shall". But I guess the "only" makes it sound slightly less optional.

Quoted 3 lines
+- New implementations of show() methods should only use sysfs_emit() or
+  sysfs_emit_at() when formatting the value to be returned to user

space.

Should we make this a "shall" for new implementations?

I'm fine either way.

Signature · 1 line
Martin K. Petersen
maintainer Applied
#3 lore raw
In reply to Bart Van Assche
Quoted 18 lines · Bart Van Assche

The advantages of converting existing sysfs show() methods to sysfs_emit() and sysfs_emit_at() do not outweigh the risk of introducing bugs. Hence recommend sysfs_emit() and sysfs_emit_at() only for new implementations of show() methods.

Cc Greg Kroah-Hartman <[email protected]>
Cc James Bottomley <[email protected]>
Cc Martin K. Petersen <[email protected]>
---
 Documentation/filesystems/sysfs.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/filesystems/sysfs.rst +0 -0
index c32993bc83c7..624e4f51212e 100644

Documentation/filesystems/sysfs.rst Other notes: · line 248

Quoted 8 lines
Documentation/filesystems/sysfs.rst +2 -2
@@ -243,8 +243,8 @@ Other notes:
 - show() methods should return the number of bytes printed into the
   buffer.
 
-- show() should only use sysfs_emit() or sysfs_emit_at() when formatting
-  the value to be returned to user space.
+- New implementations of show() methods should only use sysfs_emit() or
+  sysfs_emit_at() when formatting the value to be returned to user space.
 

Applied, thanks.

jon