[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <202212010938142826551@zte.com.cn>
Date: Thu, 1 Dec 2022 09:38:14 +0800 (CST)
From: <ye.xingchen@....com.cn>
To: <sergey.semin@...kalelectronics.ru>
Cc: <arnd@...db.de>, <linux-kernel@...r.kernel.org>
Subject: [PATCH] bus: use sysfs_emit() to instead of scnprintf()
From: ye xingchen <ye.xingchen@....com.cn>
Replace the open-code with sysfs_emit() to simplify the code.
Signed-off-by: ye xingchen <ye.xingchen@....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
Powered by blists - more mailing lists