[PATCH v3 05/14] software node: Add software_node_device_uevent() API

From: Manivannan Sadhasivam via B4 Relay

Date: Sat Jan 10 2026 - 01:57:06 EST


From: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxxxxxxxx>

Add software_node_device_uevent() API to return the uevent variable for
swnode using the DT compatible property. The uevent will have the DT prefix
of "of:N*T*C" to match the DT's module device table.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxxxxxxxx>
---
drivers/base/swnode.c | 13 +++++++++++++
include/linux/property.h | 1 +
2 files changed, 14 insertions(+)

diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index 4a3b367dea02..c33e09300e5f 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -388,6 +388,19 @@ bool software_node_match_device(struct device *dev, const struct device_driver *
}
EXPORT_SYMBOL_GPL(software_node_match_device);

+int software_node_device_uevent(const struct device *dev, struct kobj_uevent_env *env)
+{
+ const char *compatible;
+ int ret;
+
+ ret = device_property_read_string(dev, "compatible", &compatible);
+ if (ret)
+ return ret;
+
+ return add_uevent_var(env, "MODALIAS=of:N*T*C%s", compatible);
+}
+EXPORT_SYMBOL_GPL(software_node_device_uevent);
+
/* -------------------------------------------------------------------------- */
/* fwnode operations */

diff --git a/include/linux/property.h b/include/linux/property.h
index 7fe75ab732f6..14f85fd66bfc 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -599,6 +599,7 @@ int software_node_register(const struct software_node *node);
void software_node_unregister(const struct software_node *node);

bool software_node_match_device(struct device *dev, const struct device_driver *drv);
+int software_node_device_uevent(const struct device *dev, struct kobj_uevent_env *env);

struct fwnode_handle *
fwnode_create_software_node(const struct property_entry *properties,

--
2.48.1