public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: <guo.ziliang@zte.com.cn>
To: <ngupta@vflare.org>
Cc: <senozhatsky@chromium.org>, <minchan@kernel.org>,
	<axboe@kernel.dk>, <linux-kernel@vger.kernel.org>,
	<linux-block@vger.kernel.org>, <guo.ziliang@zte.com.cn>
Subject: [PATCH linux-next] zram: use sysfs_emit() to instead of scnprintf()
Date: Tue, 15 Nov 2022 09:12:08 +0800 (CST)	[thread overview]
Message-ID: <202211150912088591872@zte.com.cn> (raw)

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

Signed-off-by: guo ziliang <guo.ziliang@zte.com.cn>
---
 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

             reply	other threads:[~2022-11-15  1:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-15  1:12 guo.ziliang [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-11-14  3:41 [PATCH linux-next] zram: use sysfs_emit() to instead of scnprintf() yang.yang29
2022-11-14  4:02 ` Sergey Senozhatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202211150912088591872@zte.com.cn \
    --to=guo.ziliang@zte.com.cn \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=ngupta@vflare.org \
    --cc=senozhatsky@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox