lkml.org 
[lkml]   [2022]   [Aug]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 2/2] driver core: add compatible string in sysfs for platform devices
Date
For devices registered dynamically using platform_device_register
API, this patch exposes the sysfs entry for the compatible string.

Signed-off-by: Nipun Gupta <nipun.gupta@amd.com>
---
drivers/base/platform.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 51bb2289865c..89949f88a0a1 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1289,10 +1289,25 @@ static ssize_t driver_override_store(struct device *dev,
}
static DEVICE_ATTR_RW(driver_override);

+static ssize_t compatible_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ const char *compat;
+ int ret;
+
+ ret = device_property_read_string(dev, "compatible", &compat);
+ if (ret != 0)
+ return 0;
+
+ return sysfs_emit(buf, "%s", compat);
+}
+static DEVICE_ATTR_RO(compatible);
+
static struct attribute *platform_dev_attrs[] = {
&dev_attr_modalias.attr,
&dev_attr_numa_node.attr,
&dev_attr_driver_override.attr,
+ &dev_attr_compatible.attr,
NULL,
};

--
2.25.1
\
 
 \ /
  Last update: 2022-08-03 14:28    [W:0.680 / U:1.580 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site