[PATCH linux-next] zram: use sysfs_emit() to instead of scnprintf()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: guo ziliang <guo.ziliang@xxxxxxxxxx>
Replace the open-code with sysfs_emit() to simplify the code.)

Signed-off-by: guo ziliang <guo.ziliang@xxxxxxxxxx>
---
 drivers/block/zram/zram_drv.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 171eccc..a0399ee 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -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



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux