zram: use sysfs_emit() to instead of scnprintf()
Subsystems (2)
PATCH 1/1 zram: use sysfs_emit() to instead of scnprintf()
From: guo ziliang <[email protected]>
Replace the open-code with sysfs_emit() to simplify the code.)
Signed-off-by guo ziliang <[email protected]>
--- drivers/block/zram/zram_drv.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/block/zram/zram_drv.c +6 -5
@@ -255,7 +255,7 @@ static ssize_t initstate_show(struct device *dev, val =init_done (zram);up_read (&zram->init_lock); -return scnprintf (buf,PAGE_SIZE ,"%u\n" , val); +return sysfs_emit (buf,"%u\n" , val); } static ssize_t disksize_show(struct device *dev,
@@ -263,7 +263,7 @@ static ssize_t disksize_show(struct device *dev, {struct zram *zram =dev_to_zram (dev); -return scnprintf (buf,PAGE_SIZE ,"%llu\n" , zram->disksize); +return sysfs_emit (buf,"%llu\n" , zram->disksize); } static ssize_t mem_limit_store(struct device *dev,
@@ -404,7 +404,7 @@ static ssize_t writeback_limit_enable_show(struct device *dev,spin_unlock (&zram->wb_limit_lock);up_read (&zram->init_lock); -return scnprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); } static ssize_t writeback_limit_store(struct device *dev,
@@ -439,7 +439,7 @@ static ssize_t writeback_limit_show(struct device *dev,spin_unlock (&zram->wb_limit_lock);up_read (&zram->init_lock); -return scnprintf (buf,PAGE_SIZE ,"%llu\n" , val); +return sysfs_emit (buf,"%llu\n" , val); }static void reset_bdev (struct zram *zram)
@@ -1021,6 +1021,7 @@ static ssize_t max_comp_streams_show(struct device *dev, struct device_attribute *attr, char *buf) { return scnprintf(buf, PAGE_SIZE, "%d\n", num_online_cpus()); +return sysfs_emit (buf,"%d\n" ,num_online_cpus ()); } static ssize_t max_comp_streams_store(struct device *dev,
@@ -2504,7 +2505,7 @@ static ssize_t hot_add_show(struct class *class,if (ret <0 )return ret; -return scnprintf (buf,PAGE_SIZE ,"%d\n" , ret); +return sysfs_emit (buf,"%d\n" , ret); }static struct class_attribute class_attr_hot_add =__ATTR (hot_add,0400 , hot_add_show,NULL );
--
1.8.3.1