[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250106121017.1620-12-shiju.jose@huawei.com>
Date: Mon, 6 Jan 2025 12:10:07 +0000
From: <shiju.jose@...wei.com>
To: <linux-edac@...r.kernel.org>, <linux-cxl@...r.kernel.org>,
<linux-acpi@...r.kernel.org>, <linux-mm@...ck.org>,
<linux-kernel@...r.kernel.org>
CC: <bp@...en8.de>, <tony.luck@...el.com>, <rafael@...nel.org>,
<lenb@...nel.org>, <mchehab@...nel.org>, <dan.j.williams@...el.com>,
<dave@...olabs.net>, <jonathan.cameron@...wei.com>, <dave.jiang@...el.com>,
<alison.schofield@...el.com>, <vishal.l.verma@...el.com>,
<ira.weiny@...el.com>, <david@...hat.com>, <Vilas.Sridharan@....com>,
<leo.duran@....com>, <Yazen.Ghannam@....com>, <rientjes@...gle.com>,
<jiaqiyan@...gle.com>, <Jon.Grimm@....com>, <dave.hansen@...ux.intel.com>,
<naoya.horiguchi@....com>, <james.morse@....com>, <jthoughton@...gle.com>,
<somasundaram.a@....com>, <erdemaktas@...gle.com>, <pgonda@...gle.com>,
<duenwen@...gle.com>, <gthelen@...gle.com>, <wschwartz@...erecomputing.com>,
<dferguson@...erecomputing.com>, <wbs@...amperecomputing.com>,
<nifan.cxl@...il.com>, <yazen.ghannam@....com>, <tanxiaofei@...wei.com>,
<prime.zeng@...ilicon.com>, <roberto.sassu@...wei.com>,
<kangkang.shen@...urewei.com>, <wanghuiqiang@...wei.com>,
<linuxarm@...wei.com>, <shiju.jose@...wei.com>
Subject: [PATCH v18 11/19] cxl: Add features driver attribute to emit number of features supported
From: Dave Jiang <dave.jiang@...el.com>
Enable sysfs attribute emission of the number of features supported by the
driver/device. This is useful for userspace to determine the number of features
to query for.
Signed-off-by: Dave Jiang <dave.jiang@...el.com>
---
drivers/cxl/features.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/drivers/cxl/features.c b/drivers/cxl/features.c
index 2cdf5ed0a771..2f0fb072921e 100644
--- a/drivers/cxl/features.c
+++ b/drivers/cxl/features.c
@@ -173,11 +173,38 @@ static void cxl_features_remove(struct device *dev)
kfree(cfs);
}
+static ssize_t features_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct cxl_features_state *cfs = dev_get_drvdata(dev);
+
+ if (!cfs)
+ return -ENOENT;
+
+ return sysfs_emit(buf, "%d\n", cfs->num_features);
+}
+
+static DEVICE_ATTR_RO(features);
+
+static struct attribute *cxl_features_attrs[] = {
+ &dev_attr_features.attr,
+ NULL
+};
+
+static struct attribute_group cxl_features_group = {
+ .attrs = cxl_features_attrs,
+};
+
+__ATTRIBUTE_GROUPS(cxl_features);
+
static struct cxl_driver cxl_features_driver = {
.name = "cxl_features",
.probe = cxl_features_probe,
.remove = cxl_features_remove,
.id = CXL_DEVICE_FEATURES,
+ .drv = {
+ .dev_groups = cxl_features_groups,
+ },
};
module_cxl_driver(cxl_features_driver);
--
2.43.0
Powered by blists - more mailing lists