mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Teresa Remmet <t.remmet@phytec.de>
To: barebox@lists.infradead.org
Subject: [PATCH v2 4/7] drivers: of: Add function to enable and register a device by alias
Date: Wed, 13 Feb 2019 09:34:25 +0100	[thread overview]
Message-ID: <1550046868-19264-4-git-send-email-t.remmet@phytec.de> (raw)
In-Reply-To: <1550046868-19264-1-git-send-email-t.remmet@phytec.de>

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>
---
 drivers/of/platform.c | 19 +++++++++++++++++++
 include/of.h          |  8 ++++++++
 2 files changed, 27 insertions(+)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index ef8969ca8b19..d3795d799a13 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)
 {
diff --git a/include/of.h b/include/of.h
index 184acb474136..b5f54dd4e5b5 100644
--- a/include/of.h
+++ b/include/of.h
@@ -255,6 +255,8 @@ extern int of_platform_populate(struct device_node *root,
 extern struct device_d *of_find_device_by_node(struct device_node *np);
 extern struct device_d *of_device_enable_and_register(struct device_node *np);
 extern struct device_d *of_device_enable_and_register_by_name(const char *name);
+extern struct device_d *of_device_enable_and_register_by_alias(
+							const char *alias);
 
 struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node);
 int of_parse_partitions(struct cdev *cdev, struct device_node *node);
@@ -670,6 +672,12 @@ static inline struct device_d *of_device_enable_and_register_by_name(
 	return NULL;
 }
 
+static inline struct device_d *of_device_enable_and_register_by_alias(
+				const char *alias)
+{
+	return NULL;
+}
+
 static inline int of_register_fixup(int (*fixup)(struct device_node *, void *),
 				void *context)
 {
-- 
2.7.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2019-02-13  8:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-13  8:34 [PATCH v2 1/7] drivers: bus: Add ti-sysc bus driver Teresa Remmet
2019-02-13  8:34 ` [PATCH v2 2/7] arm: configs: omap_defconfig: Enable " Teresa Remmet
2019-02-13  8:34 ` [PATCH v2 3/7] arm: configs: am33xx_mlo_defconfig: " Teresa Remmet
2019-02-13  8:34 ` Teresa Remmet [this message]
2019-02-13  8:34 ` [PATCH v2 5/7] arm: mach-omap: am335x_generic: Enable nodes by alias where needed Teresa Remmet
2019-02-13  8:34 ` [PATCH v2 6/7] net: ethernet: cpsw: cpsw-phy-sel: Use phandle for phy sel Teresa Remmet
2019-02-13  8:34 ` [PATCH v2 7/7] arm: dts: am335x-phytec: Use phy-handle instead of phy_id Teresa Remmet
2019-02-13 19:30 ` [PATCH v2 1/7] drivers: bus: Add ti-sysc bus driver Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1550046868-19264-4-git-send-email-t.remmet@phytec.de \
    --to=t.remmet@phytec.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox