mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
To: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: barebox@lists.infradead.org
Subject: [PATCH 07/22] OF: base: sync of_find_node_by_path with linux OF API
Date: Tue, 18 Jun 2013 19:29:52 +0200	[thread overview]
Message-ID: <1371576607-8090-8-git-send-email-sebastian.hesselbarth@gmail.com> (raw)
In-Reply-To: <1371576607-8090-1-git-send-email-sebastian.hesselbarth@gmail.com>

Barebox of_find_node_by_path requires a node to be passed as start node
to start searching. Linux OF API does not pass this node and no current
user of it in barebox is passing anything else than the root node.
Therefore, the device_node argument is removed and all current users of
that function are updated to reflect the API change.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
Cc: barebox@lists.infradead.org
---
 arch/arm/boards/highbank/init.c |    4 ++--
 arch/ppc/mach-mpc5xxx/cpu.c     |    4 ++--
 commands/of_node.c              |    2 +-
 commands/of_property.c          |   10 ++--------
 commands/oftree.c               |   11 +----------
 common/oftree.c                 |    2 +-
 drivers/of/base.c               |   22 ++++++++++------------
 include/of.h                    |    9 +++++++--
 net/eth.c                       |    2 +-
 9 files changed, 27 insertions(+), 39 deletions(-)

diff --git a/arch/arm/boards/highbank/init.c b/arch/arm/boards/highbank/init.c
index d4a5c5a..1aa713b 100644
--- a/arch/arm/boards/highbank/init.c
+++ b/arch/arm/boards/highbank/init.c
@@ -53,7 +53,7 @@ static int hb_fixup(struct device_node *root)
 	if ((opp_table[0] >> 16) != HB_OPP_VERSION)
 		return 0;
 
-	node = of_find_node_by_path(root, "/cpus/cpu@0");
+	node = of_find_node_by_path("/cpus/cpu@0");
 	if (!node)
 		return 0;
 
@@ -89,7 +89,7 @@ static int highbank_mem_init(void)
 
 	of_set_root_node(root);
 
-	np = of_find_node_by_path(root, "/memory");
+	np = of_find_node_by_path("/memory");
 	if (!np) {
 		pr_warn("no memory node use default configuration\n");
 		goto not_found;
diff --git a/arch/ppc/mach-mpc5xxx/cpu.c b/arch/ppc/mach-mpc5xxx/cpu.c
index 99f16eb..0ece4a9 100644
--- a/arch/ppc/mach-mpc5xxx/cpu.c
+++ b/arch/ppc/mach-mpc5xxx/cpu.c
@@ -83,7 +83,7 @@ static int of_mpc5200_fixup(struct device_node *root)
 
 	int div = in_8((void*)CFG_MBAR + 0x204) & 0x0020 ? 8 : 4;
 
-	node = of_find_node_by_path(root, "/cpus/PowerPC,5200@0");
+	node = of_find_node_by_path("/cpus/PowerPC,5200@0");
 	if (!node)
 		return -EINVAL;
 
@@ -91,7 +91,7 @@ static int of_mpc5200_fixup(struct device_node *root)
 	of_property_write_u32(node, "bus-frequency", get_bus_clock());
 	of_property_write_u32(node, "clock-frequency", get_cpu_clock());
 
-	node = of_find_node_by_path(root, "/soc5200@f0000000");
+	node = of_find_node_by_path("/soc5200@f0000000");
 	if (!node)
 		return -EINVAL;
 
diff --git a/commands/of_node.c b/commands/of_node.c
index 0249d97..e60ef66 100644
--- a/commands/of_node.c
+++ b/commands/of_node.c
@@ -81,7 +81,7 @@ static int do_of_node(int argc, char *argv[])
 		if (!path)
 			return COMMAND_ERROR_USAGE;
 
-		node = of_find_node_by_path(root, path);
+		node = of_find_node_by_path(path);
 		if (!node) {
 			printf("Cannot find nodepath %s\n", path);
 			return -ENOENT;
diff --git a/commands/of_property.c b/commands/of_property.c
index d1a9a17..8ffe30b 100644
--- a/commands/of_property.c
+++ b/commands/of_property.c
@@ -175,7 +175,7 @@ static int do_of_property(int argc, char *argv[])
 	int set = 0;
 	int ret;
 	char *path = NULL, *propname = NULL;
-	struct device_node *root, *node = NULL;
+	struct device_node *node = NULL;
 	struct property *pp = NULL;
 
 	while ((opt = getopt(argc, argv, "ds")) > 0) {
@@ -194,15 +194,9 @@ static int do_of_property(int argc, char *argv[])
 	if (optind == argc)
 		return COMMAND_ERROR_USAGE;
 
-	root = of_get_root_node();
-	if (!root) {
-		printf("root node not set\n");
-		return -ENOENT;
-	}
-
 	if (optind < argc) {
 		path = argv[optind];
-		node = of_find_node_by_path(root, path);
+		node = of_find_node_by_path(path);
 		if (!node) {
 			printf("Cannot find nodepath %s\n", path);
 			return -ENOENT;
diff --git a/commands/oftree.c b/commands/oftree.c
index 468235a..9149517 100644
--- a/commands/oftree.c
+++ b/commands/oftree.c
@@ -164,16 +164,7 @@ static int do_oftree(int argc, char *argv[])
 			of_print_nodes(root, 0);
 			of_free(root);
 		} else {
-			struct device_node *root, *n;
-
-			root = of_get_root_node();
-			if (!root) {
-				ret = -ENOENT;
-				goto out;
-			}
-
-			n = of_find_node_by_path(root, node);
-
+			struct device_node *n = of_find_node_by_path(node);
 			if (!n) {
 				ret = -ENOENT;
 				goto out;
diff --git a/common/oftree.c b/common/oftree.c
index 475d418..aff4c28 100644
--- a/common/oftree.c
+++ b/common/oftree.c
@@ -100,7 +100,7 @@ void of_print_property(const void *data, int len)
 
 void of_print_cmdline(struct device_node *root)
 {
-	struct device_node *node = of_find_node_by_path(root, "/chosen");
+	struct device_node *node = of_find_node_by_path("/chosen");
 	const char *cmdline;
 
 	if (!node) {
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 85199b6..34793b3 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -153,7 +153,7 @@ void of_alias_scan(void)
 	if (!root_node)
 		return;
 
-	of_aliases = of_find_node_by_path(root_node, "/aliases");
+	of_aliases = of_find_node_by_path("/aliases");
 	if (!of_aliases)
 		return;
 
@@ -170,7 +170,7 @@ void of_alias_scan(void)
 		    !of_prop_cmp(pp->name, "linux,phandle"))
 			continue;
 
-		np = of_find_node_by_path(root_node, pp->value);
+		np = of_find_node_by_path(pp->value);
 		if (!np)
 			continue;
 
@@ -557,18 +557,16 @@ EXPORT_SYMBOL(of_machine_is_compatible);
 
 /**
  *	of_find_node_by_path - Find a node matching a full OF path
- *	@root:	The root node of this tree
  *	@path:	The full path to match
  *
- *	Returns a node pointer with refcount incremented, use
- *	of_node_put() on it when done.
+ *	Returns a pointer to the node found or NULL.
  */
-struct device_node *of_find_node_by_path(struct device_node *root, const char *path)
+struct device_node *of_find_node_by_path(const char *path)
 {
 	char *slash, *p, *freep;
-	struct device_node *dn = root;
+	struct device_node *dn = root_node;
 
-	if (*path != '/')
+	if (!dn || !path || *path != '/')
 		return NULL;
 
 	path++;
@@ -1156,12 +1154,12 @@ int of_probe(void)
 	if(!root_node)
 		return -ENODEV;
 
-	of_chosen = of_find_node_by_path(root_node, "/chosen");
+	of_chosen = of_find_node_by_path("/chosen");
 	of_property_read_string(root_node, "model", &of_model);
 
 	__of_parse_phandles(root_node);
 
-	memory = of_find_node_by_path(root_node, "/memory");
+	memory = of_find_node_by_path("/memory");
 	if (memory)
 		of_add_memory(memory, false);
 
@@ -1234,8 +1232,8 @@ int of_device_is_stdout_path(struct device_d *dev)
 	name = of_get_property(of_chosen, "linux,stdout-path", NULL);
 	if (name == NULL)
 		return 0;
-	dn = of_find_node_by_path(root_node, name);
 
+	dn = of_find_node_by_path(name);
 	if (!dn)
 		return 0;
 
@@ -1264,7 +1262,7 @@ int of_add_initrd(struct device_node *root, resource_size_t start,
 	struct device_node *chosen;
 	__be32 buf[2];
 
-	chosen = of_find_node_by_path(root, "/chosen");
+	chosen = of_find_node_by_path("/chosen");
 	if (!chosen)
 		return -EINVAL;
 
diff --git a/include/of.h b/include/of.h
index 7ebde62..871f5e9 100644
--- a/include/of.h
+++ b/include/of.h
@@ -67,8 +67,6 @@ int of_add_initrd(struct device_node *root, resource_size_t start,
 int of_n_addr_cells(struct device_node *np);
 int of_n_size_cells(struct device_node *np);
 
-struct device_node *of_find_node_by_path(struct device_node *root, const char *path);
-
 struct device_node *of_find_child_by_name(struct device_node *node, const char *name);
 
 struct fdt_header *fdt_get_tree(void);
@@ -184,6 +182,8 @@ struct cdev;
 extern struct property *of_find_property(const struct device_node *np,
 					const char *name, int *lenp);
 
+extern struct device_node *of_find_node_by_path(const char *path);
+
 extern void of_alias_scan(void);
 extern int of_alias_get_id(struct device_node *np, const char *stem);
 extern const char *of_alias_get(struct device_node *np);
@@ -235,6 +235,11 @@ static inline struct property *of_find_property(const struct device_node *np,
 	return NULL;
 }
 
+static inline struct device_node *of_find_node_by_path(const char *path)
+{
+	return NULL;
+}
+
 static inline void of_alias_scan(void)
 {
 }
diff --git a/net/eth.c b/net/eth.c
index 7240b4d..09b3bd5 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -296,7 +296,7 @@ static int eth_of_fixup(struct device_node *root)
 			continue;
 		}
 
-		node = of_find_node_by_path(root, edev->nodepath);
+		node = of_find_node_by_path(edev->nodepath);
 		if (!node) {
 			dev_dbg(&edev->dev, "%s: fixup node %s not found\n",
 					__func__, edev->nodepath);
-- 
1.7.2.5


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

  parent reply	other threads:[~2013-06-18 17:30 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-18 17:29 [PATCH 00/22] Barebox OF API fixes, sync, and cleanup Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 01/22] lib: string: import case-insensitive string compare Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 02/22] OF: base: bail out early on missing matches for of_match_node Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 03/22] OF: base: also update property length on of_property_write_u32 Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 04/22] OF: base: export of_alias_scan Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 05/22] OF: base: convert strcmp to default string compare functions Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 06/22] OF: base: sync of_find_property with linux OF API Sebastian Hesselbarth
2013-06-18 17:29 ` Sebastian Hesselbarth [this message]
2013-06-18 20:13   ` [PATCH 07/22] OF: base: sync of_find_node_by_path " Sascha Hauer
2013-06-18 20:19     ` Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 08/22] OF: base: rename of_node_disabled to of_device_is_available Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 09/22] OF: base: import of_find_node_by_name from Linux OF API Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 10/22] OF: base: import of_find_compatible_node " Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 11/22] OF: base: import of_find_matching_node_and_match " Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 12/22] OF: base: import of_find_node_with_property " Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 13/22] OF: base: import parent/child functions " Sebastian Hesselbarth
2013-06-18 20:18   ` Sascha Hauer
2013-06-18 20:29   ` Sascha Hauer
2013-06-18 20:34     ` Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 14/22] OF: base: import of_property_read_* helpers " Sebastian Hesselbarth
2013-06-18 17:30 ` [PATCH 15/22] OF: base: import of_parse_phandle " Sebastian Hesselbarth
2013-06-18 17:30 ` [PATCH 16/22] OF: base: import parse phandle functions " Sebastian Hesselbarth
2013-06-18 17:30 ` [PATCH 17/22] OF: base: introduce property write for bool, u8, u16, and u64 Sebastian Hesselbarth
2013-06-18 17:30 ` [PATCH 18/22] OF: base: import property iterators from Linux OF API Sebastian Hesselbarth
2013-06-18 17:30 ` [PATCH 19/22] OF: base: remove of_tree_for_each_node from public API Sebastian Hesselbarth
2013-06-18 17:30 ` [PATCH 20/22] OF: base: remove of_find_child_by_name Sebastian Hesselbarth
2013-06-18 17:30 ` [PATCH 21/22] OF: base: convert and remove device_node_for_nach_child Sebastian Hesselbarth
2013-06-18 17:30 ` [PATCH 22/22] OF: base: cleanup base function include Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 00/22] Barebox OF API fixes, sync, and cleanup Sebastian Hesselbarth
2013-06-20  9:18   ` Sascha Hauer
2013-06-19  9:09 ` [PATCH v2 01/22] lib: string: import case-insensitive string compare Sebastian Hesselbarth
2013-06-20  9:04   ` Sascha Hauer
2013-06-19  9:09 ` [PATCH v2 02/22] OF: base: bail out early on missing matches for of_match_node Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 03/22] OF: base: also update property length on of_property_write_u32 Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 04/22] OF: base: export of_alias_scan Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 05/22] OF: base: convert strcmp to default string compare functions Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 06/22] OF: base: sync of_find_property with linux OF API Sebastian Hesselbarth
2013-06-20  8:57   ` Sascha Hauer
2013-06-19  9:09 ` [PATCH v2 07/22] OF: base: sync of_find_node_by_path " Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 08/22] OF: base: rename of_node_disabled to of_device_is_available Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 09/22] OF: base: import of_find_node_by_name from Linux OF API Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 10/22] OF: base: import of_find_compatible_node " Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 11/22] OF: base: import of_find_matching_node_and_match " Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 12/22] OF: base: import of_find_node_with_property " Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 13/22] OF: base: import parent/child functions " Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 14/22] OF: base: import of_property_read_* helpers " Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 15/22] OF: base: import of_parse_phandle " Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 16/22] OF: base: import parse phandle functions " Sebastian Hesselbarth
2013-06-20  8:33   ` Sascha Hauer
2013-06-19  9:09 ` [PATCH v2 17/22] OF: base: introduce property write for bool, u8, u16, and u64 Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 18/22] OF: base: import property iterators from Linux OF API Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 19/22] OF: base: remove of_tree_for_each_node from public API Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 20/22] OF: base: remove of_find_child_by_name Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 21/22] OF: base: convert and remove device_node_for_nach_child Sebastian Hesselbarth
2013-06-19  9:09 ` [PATCH v2 22/22] OF: base: cleanup base function include Sebastian Hesselbarth

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=1371576607-8090-8-git-send-email-sebastian.hesselbarth@gmail.com \
    --to=sebastian.hesselbarth@gmail.com \
    --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