summaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
authorTeresa Remmet <t.remmet@phytec.de>2019-02-13 09:34:25 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-02-13 15:43:19 +0100
commitb1ffbd0c80ed0c7bb7612d69f0c43049f3008315 (patch)
treec2f0e14cb2a8f33fa96f34af5d5de50f78dc2f9f /drivers/of
parente63c53267c320a33aee111feb9d340b2f3bad0c1 (diff)
downloadbarebox-b1ffbd0c80ed0c7bb7612d69f0c43049f3008315.tar.gz
barebox-b1ffbd0c80ed0c7bb7612d69f0c43049f3008315.tar.xz
drivers: of: Add function to enable and register a device by alias
In some cases node names are not unique and passing the full path is really long. So make add a new device by passing the alias string possible. Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/platform.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index ef8969ca8b..d3795d799a 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -207,6 +207,25 @@ struct device_d *of_device_enable_and_register_by_name(const char *name)
}
EXPORT_SYMBOL(of_device_enable_and_register_by_name);
+/**
+ * of_device_enable_and_register_by_alias - Enable and register device by alias
+ * @name: alias of the device node
+ *
+ * Returns pointer to created platform device, or NULL if a device was not
+ * registered. Unavailable devices will not get registered.
+ */
+struct device_d *of_device_enable_and_register_by_alias(const char *alias)
+{
+ struct device_node *node;
+
+ node = of_find_node_by_alias(NULL, alias);
+ if (!node)
+ return NULL;
+
+ return of_device_enable_and_register(node);
+}
+EXPORT_SYMBOL(of_device_enable_and_register_by_alias);
+
#ifdef CONFIG_ARM_AMBA
static struct device_d *of_amba_device_create(struct device_node *np)
{