All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux-next] null_blk: use sysfs_emit() to instead of scnprintf()
@ 2022-10-21  8:54 yexingchen116
  2022-10-21  9:44 ` Damien Le Moal
  0 siblings, 1 reply; 2+ messages in thread
From: yexingchen116 @ 2022-10-21  8:54 UTC (permalink / raw)
  To: axboe
  Cc: kch, damien.lemoal, johannes.thumshirn, bvanassche, ming.lei,
	vincent.fu, shinichiro.kawasaki, linux-block, linux-kernel,
	ye xingchen

From: ye xingchen <ye.xingchen@zte.com.cn>

Replace the open-code with sysfs_emit() to simplify the code.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
---
 drivers/block/null_blk/main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 1f154f92f4c2..5317ef2ba227 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -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,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH linux-next] null_blk: use sysfs_emit() to instead of scnprintf()
  2022-10-21  8:54 [PATCH linux-next] null_blk: use sysfs_emit() to instead of scnprintf() yexingchen116
@ 2022-10-21  9:44 ` Damien Le Moal
  0 siblings, 0 replies; 2+ messages in thread
From: Damien Le Moal @ 2022-10-21  9:44 UTC (permalink / raw)
  To: yexingchen116, axboe
  Cc: kch, johannes.thumshirn, bvanassche, ming.lei, vincent.fu,
	shinichiro.kawasaki, linux-block, linux-kernel, ye xingchen

On 10/21/22 17:54, yexingchen116@gmail.com wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Replace the open-code with sysfs_emit() to simplify the code.
> 
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>

Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

> ---
>  drivers/block/null_blk/main.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
> index 1f154f92f4c2..5317ef2ba227 100644
> --- a/drivers/block/null_blk/main.c
> +++ b/drivers/block/null_blk/main.c
> @@ -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,

-- 
Damien Le Moal
Western Digital Research


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-21  9:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-21  8:54 [PATCH linux-next] null_blk: use sysfs_emit() to instead of scnprintf() yexingchen116
2022-10-21  9:44 ` Damien Le Moal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.