[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231114125648.1146-4-shiju.jose@huawei.com>
Date: Tue, 14 Nov 2023 20:56:44 +0800
From: <shiju.jose@...wei.com>
To: <linux-cxl@...r.kernel.org>
CC: <jonathan.cameron@...wei.com>, <Vilas.Sridharan@....com>,
<leo.duran@....com>, <Yazen.Ghannam@....com>,
<rientjes@...gle.com>, <jiaqiyan@...gle.com>,
<tony.luck@...el.com>, <Jon.Grimm@....com>,
<dave.hansen@...ux.intel.com>, <linux-acpi@...r.kernel.org>,
<linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
<rafael@...nel.org>, <lenb@...nel.org>, <naoya.horiguchi@....com>,
<james.morse@....com>, <david@...hat.com>, <jthoughton@...gle.com>,
<somasundaram.a@....com>, <erdemaktas@...gle.com>,
<"pgonda@...nda"@google.com>, <duenwen@...gle.com>,
<mike.malvestuto@...el.com>, <gthelen@...gle.com>,
<tanxiaofei@...wei.com>, <prime.zeng@...ilicon.com>,
<kangkang.shen@...urewei.com>, <wanghuiqiang@...wei.com>,
<linuxarm@...wei.com>, <shiju.jose@...wei.com>
Subject: [RFC PATCH 3/6] memory: scrub: Add function to show scrub attributes in decimal
From: Shiju Jose <shiju.jose@...wei.com>
Add function to show scrub control attributes to the user
in decimal.
Signed-off-by: Shiju Jose <shiju.jose@...wei.com>
---
drivers/memory/scrub/memory-scrub.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/drivers/memory/scrub/memory-scrub.c b/drivers/memory/scrub/memory-scrub.c
index b3011e7cd062..ff5b4a52d2da 100755
--- a/drivers/memory/scrub/memory-scrub.c
+++ b/drivers/memory/scrub/memory-scrub.c
@@ -130,6 +130,20 @@ static ssize_t scrub_attr_show(struct device *dev,
u64 val;
struct scrub_device_attribute *hattr = to_scrub_attr(devattr);
+ ret = hattr->ops->read(dev, hattr->attr, hattr->region_id, &val);
+ if (ret < 0)
+ return ret;
+
+ return sprintf(buf, "%lld\n", val);
+}
+
+static ssize_t scrub_attr_show_hex(struct device *dev,
+ struct device_attribute *devattr, char *buf)
+{
+ int ret;
+ u64 val;
+ struct scrub_device_attribute *hattr = to_scrub_attr(devattr);
+
ret = hattr->ops->read(dev, hattr->attr, hattr->region_id, &val);
if (ret < 0)
return ret;
@@ -236,8 +250,12 @@ static struct attribute *scrub_genattr(const void *drvdata,
hattr->region_id = region_id;
dattr = &hattr->dev_attr;
- dattr->show = is_string ? scrub_attr_show_string : scrub_attr_show;
- dattr->store = is_hex ? scrub_attr_store_hex : scrub_attr_store;
+ if (is_string) {
+ dattr->show = scrub_attr_show_string;
+ } else {
+ dattr->show = is_hex ? scrub_attr_show_hex : scrub_attr_show;
+ dattr->store = is_hex ? scrub_attr_store_hex : scrub_attr_store;
+ }
a = &dattr->attr;
sysfs_attr_init(a);
--
2.34.1
Powered by blists - more mailing lists