diff mbox series

[3/3] firmware: arm_scmi: Emit modalias for SCMI devices

Message ID 20250131141822.514342-3-sudeep.holla@arm.com (mailing list archive)
State New
Headers show
Series [1/3] firmware: arm_scmi: Relax duplicate name constraint across protocol ids | expand

Commit Message

Sudeep Holla Jan. 31, 2025, 2:18 p.m. UTC
In order to enable libkmod lookups for SCMI device objects to their
corresponding module, add 'modalias' to the base attribute of SCMI
devices.

Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/firmware/arm_scmi/bus.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c
index 862dd34eca62..7af01664ce7e 100644
--- a/drivers/firmware/arm_scmi/bus.c
+++ b/drivers/firmware/arm_scmi/bus.c
@@ -287,6 +287,17 @@  static int scmi_device_uevent(const struct device *dev, struct kobj_uevent_env *
 			      scmi_dev->name);
 }
 
+static ssize_t modalias_show(struct device *dev,
+			     struct device_attribute *attr, char *buf)
+{
+	struct scmi_device *scmi_dev = to_scmi_dev(dev);
+
+	return sysfs_emit(buf, SCMI_UEVENT_MODALIAS_FMT,
+			  dev_name(&scmi_dev->dev), scmi_dev->protocol_id,
+			  scmi_dev->name);
+}
+static DEVICE_ATTR_RO(modalias);
+
 static ssize_t protocol_id_show(struct device *dev,
 				 struct device_attribute *attr, char *buf)
 {
@@ -308,6 +319,7 @@  static DEVICE_ATTR_RO(name);
 static struct attribute *scmi_device_attributes_attrs[] = {
 	&dev_attr_protocol_id.attr,
 	&dev_attr_name.attr,
+	&dev_attr_modalias.attr,
 	NULL,
 };
 ATTRIBUTE_GROUPS(scmi_device_attributes);