Re: [PATCH v2] commands: of_dump switch to get fixed devictree

2014-08-21 Thread Jan Weitzel

Am 04.08.2014 um 21:21 schrieb Sascha Hauer:


Hi Jan,

On Fri, Aug 01, 2014 at 09:01:05AM +0200, Jan Weitzel wrote:

Add a switch to get the devicetree processed by the registered fixups.
This is also whats the kernel gets.

This is a very useful option.


Signed-off-by: Jan Weitzel j.weit...@phytec.de
---
v2: fix CMD OPS

  commands/of_dump.c |   12 ++--
  1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/commands/of_dump.c b/commands/of_dump.c
index cafde07..1b487c7 100644
--- a/commands/of_dump.c
+++ b/commands/of_dump.c
@@ -34,16 +34,20 @@ static int do_of_dump(int argc, char *argv[])
  {
int opt;
int ret;
+   int fix = 0;
struct device_node *root = NULL, *node, *of_free = NULL;
char *dtbfile = NULL;
size_t size;
const char *nodename;
  
-	while ((opt = getopt(argc, argv, f:))  0) {

+   while ((opt = getopt(argc, argv, Ff:))  0) {
switch (opt) {
case 'f':
dtbfile = optarg;
break;
+   case 'F':
+   fix = 1;
+   break;
default:
return COMMAND_ERROR_USAGE;
}
@@ -77,6 +81,9 @@ static int do_of_dump(int argc, char *argv[])
root = of_get_root_node();
}
  
+	if (fix)

+   of_get_fixed_tree(root);

of_get_fixed_tree() returns an allocated flat device tree. You should
free it.

As an alternative you could call of_fix_tree() instead.

Also I'm not sure about the API. of_fix_tree manipulates the internal
tree, so when you use of_dump -F once you'll always get the fixed tree
afterwards, even when called without -F. This might be confusing.


I'll post a patch that use of_flatten_dtb / of_unflatten_dtb to create a copy 
of the internal devicetree.


We have the same problem elsewhere in the tree though, right now I'm
unsure what to do about it. And then again, I'm on holiday, so I won't
do anything about it this month ;)


Have a nice holday :)

Jan



Sascha




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


[PATCH v2] commands: of_dump switch to get fixed devictree

2014-08-01 Thread Jan Weitzel
Add a switch to get the devicetree processed by the registered fixups.
This is also whats the kernel gets.

Signed-off-by: Jan Weitzel j.weit...@phytec.de
---
v2: fix CMD OPS

 commands/of_dump.c |   12 ++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/commands/of_dump.c b/commands/of_dump.c
index cafde07..1b487c7 100644
--- a/commands/of_dump.c
+++ b/commands/of_dump.c
@@ -34,16 +34,20 @@ static int do_of_dump(int argc, char *argv[])
 {
int opt;
int ret;
+   int fix = 0;
struct device_node *root = NULL, *node, *of_free = NULL;
char *dtbfile = NULL;
size_t size;
const char *nodename;
 
-   while ((opt = getopt(argc, argv, f:))  0) {
+   while ((opt = getopt(argc, argv, Ff:))  0) {
switch (opt) {
case 'f':
dtbfile = optarg;
break;
+   case 'F':
+   fix = 1;
+   break;
default:
return COMMAND_ERROR_USAGE;
}
@@ -77,6 +81,9 @@ static int do_of_dump(int argc, char *argv[])
root = of_get_root_node();
}
 
+   if (fix)
+   of_get_fixed_tree(root);
+
node = of_find_node_by_path_or_alias(root, nodename);
if (!node) {
printf(Cannot find nodepath %s\n, nodename);
@@ -96,12 +103,13 @@ out:
 BAREBOX_CMD_HELP_START(of_dump)
 BAREBOX_CMD_HELP_TEXT(Options:)
 BAREBOX_CMD_HELP_OPT  (-f dtb,  work on dtb instead of internal 
devicetree\n)
+BAREBOX_CMD_HELP_OPT  (-F,  return fixed devicetree\n)
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(of_dump)
.cmd= do_of_dump,
BAREBOX_CMD_DESC(dump devicetree nodes)
-   BAREBOX_CMD_OPTS([-f] [NODE])
+   BAREBOX_CMD_OPTS([-fF] [NODE])
BAREBOX_CMD_GROUP(CMD_GRP_MISC)
BAREBOX_CMD_COMPLETE(devicetree_file_complete)
BAREBOX_CMD_HELP(cmd_of_dump_help)
-- 
1.7.0.4


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