Skip to contentSkip to conversation

null_blk: convert sysfs snprintf to sysfs_emit

PATCH New Bo Liu 1 participant 1 message Feb 1, 2023 Block layer

lore
Share & tools
lore

Bo Liu

author
#0 lore raw

PATCH 1/1 null_blk: convert sysfs snprintf to sysfs_emit

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/block/null_blk/main.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/block/null_blk/main.c +4 -4
index 4c601ca9552a..7b79cda53c81 100644
@@ -255,18 +255,18 @@ static inline struct nullb_device *to_nullb_device(struct config_item *item)
 
 static inline ssize_t nullb_device_uint_attr_show(unsigned int val, char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%u\n", val);
+	return sysfs_emit(page, "%u\n", val);
 }
 
 static inline ssize_t nullb_device_ulong_attr_show(unsigned long val,
 	char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%lu\n", val);
+	return sysfs_emit(page, "%lu\n", val);
 }
 
 static inline ssize_t nullb_device_bool_attr_show(bool val, char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%u\n", val);
+	return sysfs_emit(page, "%u\n", val);
 }
 
 static ssize_t nullb_device_uint_attr_store(unsigned int *val,
@@ -627,7 +627,7 @@ nullb_group_drop_item(struct config_group *group, struct config_item *item)
 
 static ssize_t memb_group_features_show(struct config_item *item, char *page)
 {
-	return snprintf(page, PAGE_SIZE,
+	return sysfs_emit(page,
 			"badblocks,blocking,blocksize,cache_size,"
 			"completion_nsec,discard,home_node,hw_queue_depth,"
 			"irqmode,max_sectors,mbps,memory_backed,no_sched,"
Signature · 1 line
2.27.0