mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2] commands: of_dump switch to get fixed devictree
@ 2014-08-01  7:01 Jan Weitzel
  2014-08-04 19:21 ` Sascha Hauer
  0 siblings, 1 reply; 9+ messages in thread
From: Jan Weitzel @ 2014-08-01  7:01 UTC (permalink / raw)
  To: barebox

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.weitzel@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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] commands: of_dump switch to get fixed devictree
  2014-08-01  7:01 [PATCH v2] commands: of_dump switch to get fixed devictree Jan Weitzel
@ 2014-08-04 19:21 ` Sascha Hauer
  2014-08-21 11:25   ` Jan Weitzel
  2014-08-21 11:26   ` [PATCH v3] " Jan Weitzel
  0 siblings, 2 replies; 9+ messages in thread
From: Sascha Hauer @ 2014-08-04 19:21 UTC (permalink / raw)
  To: Jan Weitzel; +Cc: barebox

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.weitzel@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.
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 ;)

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] commands: of_dump switch to get fixed devictree
  2014-08-04 19:21 ` Sascha Hauer
@ 2014-08-21 11:25   ` Jan Weitzel
  2014-08-21 11:26   ` [PATCH v3] " Jan Weitzel
  1 sibling, 0 replies; 9+ messages in thread
From: Jan Weitzel @ 2014-08-21 11:25 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

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.weitzel@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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3] commands: of_dump switch to get fixed devictree
  2014-08-04 19:21 ` Sascha Hauer
  2014-08-21 11:25   ` Jan Weitzel
@ 2014-08-21 11:26   ` Jan Weitzel
  2014-08-21 12:15     ` Antony Pavlov
  2014-09-01 10:38     ` Sascha Hauer
  1 sibling, 2 replies; 9+ messages in thread
From: Jan Weitzel @ 2014-08-21 11:26 UTC (permalink / raw)
  To: barebox

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.weitzel@phytec.de>
---
v3: create a copy of the internal devicetree before use of_fix_tree

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

diff --git a/commands/of_dump.c b/commands/of_dump.c
index cafde07..f82f0fd 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;
 		}
@@ -75,6 +79,28 @@ static int do_of_dump(int argc, char *argv[])
 		of_free = root;
 	} else {
 		root = of_get_root_node();
+
+		if (fix) {
+			/* create a copy of internal devicetree */
+			void *fdt;
+			fdt = of_flatten_dtb(root);
+			root = of_unflatten_dtb(fdt);
+
+			free(fdt);
+
+			if (IS_ERR(root)) {
+				ret = PTR_ERR(root);
+				goto out;
+			}
+
+			of_free = root;
+		}
+	}
+
+	if (fix) {
+		ret = of_fix_tree(root);
+		if (ret)
+			goto out;
 	}
 
 	node = of_find_node_by_path_or_alias(root, nodename);
@@ -96,12 +122,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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3] commands: of_dump switch to get fixed devictree
  2014-08-21 11:26   ` [PATCH v3] " Jan Weitzel
@ 2014-08-21 12:15     ` Antony Pavlov
  2014-08-21 12:15       ` [PATCH v4] " Jan Weitzel
  2014-09-01 10:34       ` [PATCH v3] " Sascha Hauer
  2014-09-01 10:38     ` Sascha Hauer
  1 sibling, 2 replies; 9+ messages in thread
From: Antony Pavlov @ 2014-08-21 12:15 UTC (permalink / raw)
  To: Jan Weitzel; +Cc: barebox

On Thu, 21 Aug 2014 13:26:19 +0200
Jan Weitzel <j.weitzel@phytec.de> wrote:

> 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.weitzel@phytec.de>
> ---
> v3: create a copy of the internal devicetree before use of_fix_tree
> 
>  commands/of_dump.c |   31 +++++++++++++++++++++++++++++--
>  1 files changed, 29 insertions(+), 2 deletions(-)
> 
> diff --git a/commands/of_dump.c b/commands/of_dump.c
> index cafde07..f82f0fd 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;
>  		}
> @@ -75,6 +79,28 @@ static int do_of_dump(int argc, char *argv[])
>  		of_free = root;
>  	} else {
>  		root = of_get_root_node();
> +
> +		if (fix) {
> +			/* create a copy of internal devicetree */
> +			void *fdt;
> +			fdt = of_flatten_dtb(root);
> +			root = of_unflatten_dtb(fdt);
> +
> +			free(fdt);
> +
> +			if (IS_ERR(root)) {
> +				ret = PTR_ERR(root);
> +				goto out;
> +			}
> +
> +			of_free = root;
> +		}
> +	}
> +
> +	if (fix) {
> +		ret = of_fix_tree(root);
> +		if (ret)
> +			goto out;
>  	}
>  
>  	node = of_find_node_by_path_or_alias(root, nodename);
> @@ -96,12 +122,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]")

This is a bit confusing. The '-f' option has one argument,
but '-F' option has noone. 

IMHO this solution is more accurate:

+	BAREBOX_CMD_OPTS("[-F] [-f 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


-- 
-- 
Best regards,
  Antony Pavlov

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v4] commands: of_dump switch to get fixed devictree
  2014-08-21 12:15     ` Antony Pavlov
@ 2014-08-21 12:15       ` Jan Weitzel
  2014-09-01 10:34       ` [PATCH v3] " Sascha Hauer
  1 sibling, 0 replies; 9+ messages in thread
From: Jan Weitzel @ 2014-08-21 12:15 UTC (permalink / raw)
  To: barebox

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.weitzel@phytec.de>
---
---
v3: create a copy of the internal devicetree before use of_fix_tree
v4: fix option description

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

diff --git a/commands/of_dump.c b/commands/of_dump.c
index 315dbba..7deaea4 100644
--- a/commands/of_dump.c
+++ b/commands/of_dump.c
@@ -35,16 +35,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;
 		}
@@ -76,6 +80,28 @@ static int do_of_dump(int argc, char *argv[])
 		of_free = root;
 	} else {
 		root = of_get_root_node();
+
+		if (fix) {
+			/* create a copy of internal devicetree */
+			void *fdt;
+			fdt = of_flatten_dtb(root);
+			root = of_unflatten_dtb(fdt);
+
+			free(fdt);
+
+			if (IS_ERR(root)) {
+				ret = PTR_ERR(root);
+				goto out;
+			}
+
+			of_free = root;
+		}
+	}
+
+	if (fix) {
+		ret = of_fix_tree(root);
+		if (ret)
+			goto out;
 	}
 
 	node = of_find_node_by_path_or_alias(root, nodename);
@@ -97,12 +123,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("[-F] [-f dtb] [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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3] commands: of_dump switch to get fixed devictree
  2014-08-21 12:15     ` Antony Pavlov
  2014-08-21 12:15       ` [PATCH v4] " Jan Weitzel
@ 2014-09-01 10:34       ` Sascha Hauer
  1 sibling, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2014-09-01 10:34 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Thu, Aug 21, 2014 at 04:15:07PM +0400, Antony Pavlov wrote:
> On Thu, 21 Aug 2014 13:26:19 +0200
> Jan Weitzel <j.weitzel@phytec.de> wrote:
> 
> > Add a switch to get the devicetree processed by the registered fixups.
> > This is also whats the kernel gets.
> > 
> >  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]")
> 
> This is a bit confusing. The '-f' option has one argument,
> but '-F' option has noone.
> 
> IMHO this solution is more accurate:
> 
> +	BAREBOX_CMD_OPTS("[-F] [-f NODE]")

Indeed it's more accurate, but the way Jan did it is in line with the
other commands.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3] commands: of_dump switch to get fixed devictree
  2014-08-21 11:26   ` [PATCH v3] " Jan Weitzel
  2014-08-21 12:15     ` Antony Pavlov
@ 2014-09-01 10:38     ` Sascha Hauer
  2014-09-01 13:28       ` Jan Weitzel
  1 sibling, 1 reply; 9+ messages in thread
From: Sascha Hauer @ 2014-09-01 10:38 UTC (permalink / raw)
  To: Jan Weitzel; +Cc: barebox

On Thu, Aug 21, 2014 at 01:26:19PM +0200, Jan Weitzel wrote:
> 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.weitzel@phytec.de>
> ---
> v3: create a copy of the internal devicetree before use of_fix_tree
> 
>  commands/of_dump.c |   31 +++++++++++++++++++++++++++++--
>  1 files changed, 29 insertions(+), 2 deletions(-)
> 
> diff --git a/commands/of_dump.c b/commands/of_dump.c
> index cafde07..f82f0fd 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;
>  		}
> @@ -75,6 +79,28 @@ static int do_of_dump(int argc, char *argv[])
>  		of_free = root;
>  	} else {
>  		root = of_get_root_node();
> +
> +		if (fix) {
> +			/* create a copy of internal devicetree */
> +			void *fdt;
> +			fdt = of_flatten_dtb(root);
> +			root = of_unflatten_dtb(fdt);

That's really a creative way to make a copy of the device tree ;)

Ok, I'll close both eyes while applying it.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3] commands: of_dump switch to get fixed devictree
  2014-09-01 10:38     ` Sascha Hauer
@ 2014-09-01 13:28       ` Jan Weitzel
  0 siblings, 0 replies; 9+ messages in thread
From: Jan Weitzel @ 2014-09-01 13:28 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Am 01.09.2014 um 12:38 schrieb Sascha Hauer:
> On Thu, Aug 21, 2014 at 01:26:19PM +0200, Jan Weitzel wrote:
>> 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.weitzel@phytec.de>
>> ---
>> v3: create a copy of the internal devicetree before use of_fix_tree
>>
>>   commands/of_dump.c |   31 +++++++++++++++++++++++++++++--
>>   1 files changed, 29 insertions(+), 2 deletions(-)
>>
>> diff --git a/commands/of_dump.c b/commands/of_dump.c
>> index cafde07..f82f0fd 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;
>>   		}
>> @@ -75,6 +79,28 @@ static int do_of_dump(int argc, char *argv[])
>>   		of_free = root;
>>   	} else {
>>   		root = of_get_root_node();
>> +
>> +		if (fix) {
>> +			/* create a copy of internal devicetree */
>> +			void *fdt;
>> +			fdt = of_flatten_dtb(root);
>> +			root = of_unflatten_dtb(fdt);
> That's really a creative way to make a copy of the device tree ;)

And it use known good functions ;)

Jan

>
> Ok, I'll close both eyes while applying it.
>
> Sascha
>


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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-09-01 13:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-01  7:01 [PATCH v2] commands: of_dump switch to get fixed devictree Jan Weitzel
2014-08-04 19:21 ` Sascha Hauer
2014-08-21 11:25   ` Jan Weitzel
2014-08-21 11:26   ` [PATCH v3] " Jan Weitzel
2014-08-21 12:15     ` Antony Pavlov
2014-08-21 12:15       ` [PATCH v4] " Jan Weitzel
2014-09-01 10:34       ` [PATCH v3] " Sascha Hauer
2014-09-01 10:38     ` Sascha Hauer
2014-09-01 13:28       ` Jan Weitzel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox