lkml.org 
[lkml]   [2022]   [Nov]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] bus: use sysfs emit() to instead of scnprintf()
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
\
 
 \ /
  Last update: 2022-12-01 02:38    [W:0.036 / U:0.748 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site