mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: <ye.xingchen@zte.com.cn>
To: <sergey.semin@baikalelectronics.ru>
Cc: <arnd@arndb.de>, <linux-kernel@vger.kernel.org>
Subject: [PATCH] bus: use sysfs_emit() to instead of scnprintf()
Date: Thu, 1 Dec 2022 09:38:14 +0800 (CST)	[thread overview]
Message-ID: <202212010938142826551@zte.com.cn> (raw)

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/bus/bt1-apb.c | 6 +++---
 drivers/bus/bt1-axi.c | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/bus/bt1-apb.c b/drivers/bus/bt1-apb.c
index 63b1b4a76671..bcf10f1d6dc1 100644
--- a/drivers/bus/bt1-apb.c
+++ b/drivers/bus/bt1-apb.c
@@ -265,7 +265,7 @@ static ssize_t count_show(struct device *dev, struct device_attribute *attr,
 {
 	struct bt1_apb *apb = dev_get_drvdata(dev);

-	return scnprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&apb->count));
+	return sysfs_emit(buf, "%d\n", atomic_read(&apb->count));
 }
 static DEVICE_ATTR_RO(count);

@@ -283,7 +283,7 @@ static ssize_t timeout_show(struct device *dev, struct device_attribute *attr,

 	timeout = bt1_apb_n_to_timeout_us(apb, n);

-	return scnprintf(buf, PAGE_SIZE, "%lu\n", timeout);
+	return sysfs_emit(buf, "%lu\n", timeout);
 }

 static ssize_t timeout_store(struct device *dev,
@@ -310,7 +310,7 @@ static DEVICE_ATTR_RW(timeout);
 static ssize_t inject_error_show(struct device *dev,
 				 struct device_attribute *attr, char *buf)
 {
-	return scnprintf(buf, PAGE_SIZE, "Error injection: nodev irq\n");
+	return sysfs_emit(buf, "Error injection: nodev irq\n");
 }

 static ssize_t inject_error_store(struct device *dev,
diff --git a/drivers/bus/bt1-axi.c b/drivers/bus/bt1-axi.c
index 70e49a6e5374..04c14821bb3c 100644
--- a/drivers/bus/bt1-axi.c
+++ b/drivers/bus/bt1-axi.c
@@ -197,14 +197,14 @@ static ssize_t count_show(struct device *dev,
 {
 	struct bt1_axi *axi = dev_get_drvdata(dev);

-	return scnprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&axi->count));
+	return sysfs_emit(buf, "%d\n", atomic_read(&axi->count));
 }
 static DEVICE_ATTR_RO(count);

 static ssize_t inject_error_show(struct device *dev,
 				 struct device_attribute *attr, char *buf)
 {
-	return scnprintf(buf, PAGE_SIZE, "Error injection: bus unaligned\n");
+	return sysfs_emit(buf, "Error injection: bus unaligned\n");
 }

 static ssize_t inject_error_store(struct device *dev,
-- 
2.25.1

             reply	other threads:[~2022-12-01  1:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-01  1:38 ye.xingchen [this message]
2022-12-05  0:53 ` Serge Semin

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=202212010938142826551@zte.com.cn \
    --to=ye.xingchen@zte.com.cn \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sergey.semin@baikalelectronics.ru \
    /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

all inboxes | Powered by JetHome®