[PATCH] of: implement of_device_enable_by_alias

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Jan 16 05:35:00 PST 2023


For symmetry with of_device_disable, which already has direct, path and
by alias variants, implement the missing of_device_enable_by alias as
well.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 drivers/of/base.c | 15 +++++++++++++++
 include/of.h      |  1 +
 2 files changed, 16 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 9504ac47cb09..937847f44ab7 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2789,6 +2789,21 @@ int of_device_enable_path(const char *path)
 	return of_device_enable(node);
 }
 
+/**
+ * of_device_enable_by_alias - enable a device node by alias
+ * @alias - the alias of the device tree node to enable
+ */
+int of_device_enable_by_alias(const char *alias)
+{
+	struct device_node *node;
+
+	node = of_find_node_by_alias(NULL, alias);
+	if (!node)
+		return -ENODEV;
+
+	return of_device_enable(node);
+}
+
 /**
  * of_device_disable - disable a devicenode device
  * @node - the node to disable
diff --git a/include/of.h b/include/of.h
index 4f4e9248ada9..7ee1304b932b 100644
--- a/include/of.h
+++ b/include/of.h
@@ -1146,6 +1146,7 @@ extern const struct of_device_id of_default_bus_match_table[];
 
 int of_device_enable(struct device_node *node);
 int of_device_enable_path(const char *path);
+int of_device_enable_by_alias(const char *alias);
 int of_device_disable(struct device_node *node);
 int of_device_disable_path(const char *path);
 int of_device_disable_by_alias(const char *alias);
-- 
2.30.2




More information about the barebox mailing list