All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v4 00/13] cmd: fdt: Add device tree overlays support
@ 2016-07-05  8:26 ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: u-boot

Hi,

The device tree overlays are a great solution to the issue raised by
the bunch expandable boards we find everywhere these days, like the
Beaglebone, Raspberry Pi or CHIP.

However, most of the time, the overlays are applied through a
mechanism involving the firmware request interface in Linux, that is
only fully functional once the userspace has been mounted and is
running.

Some expansion boards might need to be enabled before that, because
they simply need to patch the DT early on, or need to be initialized
early in order to be fully functional, or because they provide access
to the root filesystem.

In these cases, having the bootloader applying the overlay before
Linux starts seems like the easiest solution.

This implementation doesn't provide all the Linux fancyness though,
there's no transactional application, which means that if the overlay
cannot be applied for a reason while you're still halfway through the
application, you're probably screwed. It also cannot remove an
overlay, but I don't think that it is currently a use-case.

There's still a bunch of work to extend the libfdt unit tests to test
the new functions introduced, but these patches will be submitted
in a near future, once things settle down.

Let me know what you think,
Maxime

Changes from v3:
  - Moved the patch to introduce fdt_getprop_namelen_w earlier to keep
    bisectability
  - Renamed fdt_setprop_inplace_namelen_by_index in
    fdt_setprop_inplace_namelen_partial
  - Reintroduced the check on the property length in fdt_setprop_inplace
  - Made sure the code was taking the non 32bits-aligned phandles
  - Used memchr instead of strchr in the fixup parsing code, and made
    sure the cases where the fixup format was wrong was reported as an
    error.
  - Fixed a bug where a property in a overlay having multiple phandles
    local to that overlay would only resolve the first one. Also added
    a test case for this
  - Added kerneldocs for all the overlay functions
  - Added a patch to fix a typo in separator
  - A few fixes, function renamings, error checking changes here and there

Changes from v2:
  - Add Kconfig option for the libfdt overlay support
  - Reworked the code to deal with Pantelis and David numerous
    comments, among which:
    * Remove the need for malloc in the overlay code, and added some
      libfdt functions to do that
    * Remove the DT magic in case of an error to not be able to use it
      anymore
    * Removed the fdt_ and _ function prefix for the static functions
    * Plus the usual bunch of rework, error checking and optimizations.

  - Added new tests to deal with bugs reported by David (the overlay
    was not applying when you add a subnode declared that was already
    in the base device tree, and using a local phandle was only
    working if the property storing it only had a length of 4).

Changes from v1:
  - Moved the overlay code to libfdt
  - Added unit tests
  - Refactored the code to reduce the amount of memory allocation
  - No longer modify the overlay itself, but create a copy to operate
    on instead.
  - Removed the limitations on the fixups path, names and properties
    length
  - Fixed a few things here and there according to comments
		    

Maxime Ripard (13):
  cmd: fdt: Narrow the check for fdt addr
  scripts: Makefile.lib: Sanitize DTB names
  vsprintf: Include stdarg for va_list
  libfdt: Add new headers and defines
  libfdt: Add iterator over properties
  libfdt: Add max phandle retrieval function
  libfdt: Fix separator spelling
  libfdt: Add fdt_path_offset_namelen
  libfdt: Add fdt_getprop_namelen_w
  libfdt: Add fdt_setprop_inplace_namelen_partial
  libfdt: Add overlay application function
  cmd: fdt: add fdt overlay application subcommand
  tests: Introduce DT overlay tests

 Makefile                          |   1 +
 cmd/fdt.c                         |  26 +-
 include/libfdt.h                  | 111 ++++++-
 include/libfdt_env.h              |   6 +
 include/test/overlay.h            |  16 +
 include/test/suites.h             |   1 +
 include/vsprintf.h                |   2 +
 lib/Kconfig                       |   5 +
 lib/libfdt/Makefile               |   2 +
 lib/libfdt/fdt_overlay.c          | 618 ++++++++++++++++++++++++++++++++++++++
 lib/libfdt/fdt_ro.c               |  46 ++-
 lib/libfdt/fdt_wip.c              |  29 +-
 scripts/Makefile.lib              |   8 +-
 test/Kconfig                      |   1 +
 test/cmd_ut.c                     |   6 +
 test/overlay/Kconfig              |  11 +
 test/overlay/Makefile             |  15 +
 test/overlay/cmd_ut_overlay.c     | 268 +++++++++++++++++
 test/overlay/test-fdt-base.dts    |  21 ++
 test/overlay/test-fdt-overlay.dts |  96 ++++++
 20 files changed, 1270 insertions(+), 19 deletions(-)
 create mode 100644 include/test/overlay.h
 create mode 100644 lib/libfdt/fdt_overlay.c
 create mode 100644 test/overlay/Kconfig
 create mode 100644 test/overlay/Makefile
 create mode 100644 test/overlay/cmd_ut_overlay.c
 create mode 100644 test/overlay/test-fdt-base.dts
 create mode 100644 test/overlay/test-fdt-overlay.dts

-- 
2.9.0

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

* [PATCH v4 00/13] cmd: fdt: Add device tree overlays support
@ 2016-07-05  8:26 ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: Pantelis Antoniou, Simon Glass
  Cc: Boris Brezillon, Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner, David Gibson, Maxime Ripard

Hi,

The device tree overlays are a great solution to the issue raised by
the bunch expandable boards we find everywhere these days, like the
Beaglebone, Raspberry Pi or CHIP.

However, most of the time, the overlays are applied through a
mechanism involving the firmware request interface in Linux, that is
only fully functional once the userspace has been mounted and is
running.

Some expansion boards might need to be enabled before that, because
they simply need to patch the DT early on, or need to be initialized
early in order to be fully functional, or because they provide access
to the root filesystem.

In these cases, having the bootloader applying the overlay before
Linux starts seems like the easiest solution.

This implementation doesn't provide all the Linux fancyness though,
there's no transactional application, which means that if the overlay
cannot be applied for a reason while you're still halfway through the
application, you're probably screwed. It also cannot remove an
overlay, but I don't think that it is currently a use-case.

There's still a bunch of work to extend the libfdt unit tests to test
the new functions introduced, but these patches will be submitted
in a near future, once things settle down.

Let me know what you think,
Maxime

Changes from v3:
  - Moved the patch to introduce fdt_getprop_namelen_w earlier to keep
    bisectability
  - Renamed fdt_setprop_inplace_namelen_by_index in
    fdt_setprop_inplace_namelen_partial
  - Reintroduced the check on the property length in fdt_setprop_inplace
  - Made sure the code was taking the non 32bits-aligned phandles
  - Used memchr instead of strchr in the fixup parsing code, and made
    sure the cases where the fixup format was wrong was reported as an
    error.
  - Fixed a bug where a property in a overlay having multiple phandles
    local to that overlay would only resolve the first one. Also added
    a test case for this
  - Added kerneldocs for all the overlay functions
  - Added a patch to fix a typo in separator
  - A few fixes, function renamings, error checking changes here and there

Changes from v2:
  - Add Kconfig option for the libfdt overlay support
  - Reworked the code to deal with Pantelis and David numerous
    comments, among which:
    * Remove the need for malloc in the overlay code, and added some
      libfdt functions to do that
    * Remove the DT magic in case of an error to not be able to use it
      anymore
    * Removed the fdt_ and _ function prefix for the static functions
    * Plus the usual bunch of rework, error checking and optimizations.

  - Added new tests to deal with bugs reported by David (the overlay
    was not applying when you add a subnode declared that was already
    in the base device tree, and using a local phandle was only
    working if the property storing it only had a length of 4).

Changes from v1:
  - Moved the overlay code to libfdt
  - Added unit tests
  - Refactored the code to reduce the amount of memory allocation
  - No longer modify the overlay itself, but create a copy to operate
    on instead.
  - Removed the limitations on the fixups path, names and properties
    length
  - Fixed a few things here and there according to comments
		    

Maxime Ripard (13):
  cmd: fdt: Narrow the check for fdt addr
  scripts: Makefile.lib: Sanitize DTB names
  vsprintf: Include stdarg for va_list
  libfdt: Add new headers and defines
  libfdt: Add iterator over properties
  libfdt: Add max phandle retrieval function
  libfdt: Fix separator spelling
  libfdt: Add fdt_path_offset_namelen
  libfdt: Add fdt_getprop_namelen_w
  libfdt: Add fdt_setprop_inplace_namelen_partial
  libfdt: Add overlay application function
  cmd: fdt: add fdt overlay application subcommand
  tests: Introduce DT overlay tests

 Makefile                          |   1 +
 cmd/fdt.c                         |  26 +-
 include/libfdt.h                  | 111 ++++++-
 include/libfdt_env.h              |   6 +
 include/test/overlay.h            |  16 +
 include/test/suites.h             |   1 +
 include/vsprintf.h                |   2 +
 lib/Kconfig                       |   5 +
 lib/libfdt/Makefile               |   2 +
 lib/libfdt/fdt_overlay.c          | 618 ++++++++++++++++++++++++++++++++++++++
 lib/libfdt/fdt_ro.c               |  46 ++-
 lib/libfdt/fdt_wip.c              |  29 +-
 scripts/Makefile.lib              |   8 +-
 test/Kconfig                      |   1 +
 test/cmd_ut.c                     |   6 +
 test/overlay/Kconfig              |  11 +
 test/overlay/Makefile             |  15 +
 test/overlay/cmd_ut_overlay.c     | 268 +++++++++++++++++
 test/overlay/test-fdt-base.dts    |  21 ++
 test/overlay/test-fdt-overlay.dts |  96 ++++++
 20 files changed, 1270 insertions(+), 19 deletions(-)
 create mode 100644 include/test/overlay.h
 create mode 100644 lib/libfdt/fdt_overlay.c
 create mode 100644 test/overlay/Kconfig
 create mode 100644 test/overlay/Makefile
 create mode 100644 test/overlay/cmd_ut_overlay.c
 create mode 100644 test/overlay/test-fdt-base.dts
 create mode 100644 test/overlay/test-fdt-overlay.dts

-- 
2.9.0

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

* [U-Boot] [PATCH v4 01/13] cmd: fdt: Narrow the check for fdt addr
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: u-boot

The current code only checks if the fdt subcommand is fdt addr by checking
whether it starts with 'a'.

Since this is a pretty widely used letter, narrow down that check a bit.

Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 cmd/fdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 898217ffe5f8..0f5923e75a41 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -87,7 +87,7 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	/*
 	 * Set the address of the fdt
 	 */
-	if (argv[1][0] == 'a') {
+	if (strncmp(argv[1], "ad", 2) == 0) {
 		unsigned long addr;
 		int control = 0;
 		struct fdt_header *blob;
-- 
2.9.0

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

* [PATCH v4 01/13] cmd: fdt: Narrow the check for fdt addr
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: Pantelis Antoniou, Simon Glass
  Cc: Boris Brezillon, Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner, David Gibson, Maxime Ripard

The current code only checks if the fdt subcommand is fdt addr by checking
whether it starts with 'a'.

Since this is a pretty widely used letter, narrow down that check a bit.

Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 cmd/fdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 898217ffe5f8..0f5923e75a41 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -87,7 +87,7 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	/*
 	 * Set the address of the fdt
 	 */
-	if (argv[1][0] == 'a') {
+	if (strncmp(argv[1], "ad", 2) == 0) {
 		unsigned long addr;
 		int control = 0;
 		struct fdt_header *blob;
-- 
2.9.0

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

* [U-Boot] [PATCH v4 02/13] scripts: Makefile.lib: Sanitize DTB names
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: u-boot

Having dashes as a separator in the DTB name is a quite common practice.

However, the current code to generate objects from DTBs assumes the
separator is an underscore, leading to a compilation error when building a
device tree with dashes.

Replace all the dashes in the DTB name to generate the symbols name, which
should solve this issue.

Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 scripts/Makefile.lib | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index e720562623c9..45a0e1d486c0 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -275,11 +275,11 @@ cmd_dt_S_dtb=						\
 (							\
 	echo '.section .dtb.init.rodata,"a"';		\
 	echo '.balign 16';				\
-	echo '.global __dtb_$(*F)_begin';		\
-	echo '__dtb_$(*F)_begin:';			\
+	echo '.global __dtb_$(subst -,_,$(*F))_begin';	\
+	echo '__dtb_$(subst -,_,$(*F))_begin:';		\
 	echo '.incbin "$<" ';				\
-	echo '__dtb_$(*F)_end:';			\
-	echo '.global __dtb_$(*F)_end';			\
+	echo '__dtb_$(subst -,_,$(*F))_end:';		\
+	echo '.global __dtb_$(subst -,_,$(*F))_end';	\
 	echo '.balign 16';				\
 ) > $@
 
-- 
2.9.0

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

* [PATCH v4 02/13] scripts: Makefile.lib: Sanitize DTB names
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: Pantelis Antoniou, Simon Glass
  Cc: Boris Brezillon, Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner, David Gibson, Maxime Ripard

Having dashes as a separator in the DTB name is a quite common practice.

However, the current code to generate objects from DTBs assumes the
separator is an underscore, leading to a compilation error when building a
device tree with dashes.

Replace all the dashes in the DTB name to generate the symbols name, which
should solve this issue.

Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 scripts/Makefile.lib | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index e720562623c9..45a0e1d486c0 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -275,11 +275,11 @@ cmd_dt_S_dtb=						\
 (							\
 	echo '.section .dtb.init.rodata,"a"';		\
 	echo '.balign 16';				\
-	echo '.global __dtb_$(*F)_begin';		\
-	echo '__dtb_$(*F)_begin:';			\
+	echo '.global __dtb_$(subst -,_,$(*F))_begin';	\
+	echo '__dtb_$(subst -,_,$(*F))_begin:';		\
 	echo '.incbin "$<" ';				\
-	echo '__dtb_$(*F)_end:';			\
-	echo '.global __dtb_$(*F)_end';			\
+	echo '__dtb_$(subst -,_,$(*F))_end:';		\
+	echo '.global __dtb_$(subst -,_,$(*F))_end';	\
 	echo '.balign 16';				\
 ) > $@
 
-- 
2.9.0

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

* [U-Boot] [PATCH v4 03/13] vsprintf: Include stdarg for va_list
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: u-boot

vsprintf.h doesn't include the stdarg.h file, which means that it relies on
the files that include vsprintf.h to include stdarg.h as well.

Add an explicit include to avoid build errors when simply including that
file.

Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 include/vsprintf.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/vsprintf.h b/include/vsprintf.h
index 376f5dd32499..60e91d119eee 100644
--- a/include/vsprintf.h
+++ b/include/vsprintf.h
@@ -8,6 +8,8 @@
 #ifndef __VSPRINTF_H
 #define __VSPRINTF_H
 
+#include <stdarg.h>
+
 ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
 
 /**
-- 
2.9.0

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

* [PATCH v4 03/13] vsprintf: Include stdarg for va_list
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: Pantelis Antoniou, Simon Glass
  Cc: Boris Brezillon, Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner, David Gibson, Maxime Ripard

vsprintf.h doesn't include the stdarg.h file, which means that it relies on
the files that include vsprintf.h to include stdarg.h as well.

Add an explicit include to avoid build errors when simply including that
file.

Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 include/vsprintf.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/vsprintf.h b/include/vsprintf.h
index 376f5dd32499..60e91d119eee 100644
--- a/include/vsprintf.h
+++ b/include/vsprintf.h
@@ -8,6 +8,8 @@
 #ifndef __VSPRINTF_H
 #define __VSPRINTF_H
 
+#include <stdarg.h>
+
 ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
 
 /**
-- 
2.9.0

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

* [U-Boot] [PATCH v4 04/13] libfdt: Add new headers and defines
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: u-boot

The libfdt overlay support introduces a bunch of new includes and
functions.

Make sure we are able to build it by adding the needed glue.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Simon Glass <sjg@chromium.org>
---
 include/libfdt_env.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/libfdt_env.h b/include/libfdt_env.h
index 273b5d30f867..6c6845f76cf7 100644
--- a/include/libfdt_env.h
+++ b/include/libfdt_env.h
@@ -23,6 +23,12 @@ typedef __be64 fdt64_t;
 #define fdt64_to_cpu(x)		be64_to_cpu(x)
 #define cpu_to_fdt64(x)		cpu_to_be64(x)
 
+#ifdef __UBOOT__
+#include <vsprintf.h>
+
+#define strtoul(cp, endp, base)	simple_strtoul(cp, endp, base)
+#endif
+
 /* adding a ramdisk needs 0x44 bytes in version 2008.10 */
 #define FDT_RAMDISK_OVERHEAD	0x80
 
-- 
2.9.0

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

* [PATCH v4 04/13] libfdt: Add new headers and defines
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: Pantelis Antoniou, Simon Glass
  Cc: Boris Brezillon, Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner, David Gibson, Maxime Ripard

The libfdt overlay support introduces a bunch of new includes and
functions.

Make sure we are able to build it by adding the needed glue.

Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 include/libfdt_env.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/libfdt_env.h b/include/libfdt_env.h
index 273b5d30f867..6c6845f76cf7 100644
--- a/include/libfdt_env.h
+++ b/include/libfdt_env.h
@@ -23,6 +23,12 @@ typedef __be64 fdt64_t;
 #define fdt64_to_cpu(x)		be64_to_cpu(x)
 #define cpu_to_fdt64(x)		cpu_to_be64(x)
 
+#ifdef __UBOOT__
+#include <vsprintf.h>
+
+#define strtoul(cp, endp, base)	simple_strtoul(cp, endp, base)
+#endif
+
 /* adding a ramdisk needs 0x44 bytes in version 2008.10 */
 #define FDT_RAMDISK_OVERHEAD	0x80
 
-- 
2.9.0

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

* [U-Boot] [PATCH v4 05/13] libfdt: Add iterator over properties
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: u-boot

Implement a macro based on fdt_first_property_offset and
fdt_next_property_offset that provides a convenience to iterate over all
the properties of a given node.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Simon Glass <sjg@chromium.org>
---
 include/libfdt.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/include/libfdt.h b/include/libfdt.h
index 74b1d149c2dd..fbbe58ceb3f1 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -440,6 +440,30 @@ int fdt_first_property_offset(const void *fdt, int nodeoffset);
  */
 int fdt_next_property_offset(const void *fdt, int offset);
 
+/**
+ * fdt_for_each_property - iterate over all properties of a node
+ * @property_offset:	property offset (int)
+ * @fdt:		FDT blob (const void *)
+ * @node:		node offset (int)
+ *
+ * This is actually a wrapper around a for loop and would be used like so:
+ *
+ *	fdt_for_each_property(fdt, node, property) {
+ *		...
+ *		use property
+ *		...
+ *	}
+ *
+ * Note that this is implemented as a macro and property is used as
+ * iterator in the loop. It should therefore be a locally allocated
+ * variable. The node variable on the other hand is never modified, so
+ * it can be constant or even a literal.
+ */
+#define fdt_for_each_property_offset(property, fdt, node)	\
+	for (property = fdt_first_property_offset(fdt, node);	\
+	     property >= 0;					\
+	     property = fdt_next_property_offset(fdt, property))
+
 /**
  * fdt_get_property_by_offset - retrieve the property at a given offset
  * @fdt: pointer to the device tree blob
-- 
2.9.0

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

* [PATCH v4 05/13] libfdt: Add iterator over properties
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: Pantelis Antoniou, Simon Glass
  Cc: Boris Brezillon, Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner, David Gibson, Maxime Ripard

Implement a macro based on fdt_first_property_offset and
fdt_next_property_offset that provides a convenience to iterate over all
the properties of a given node.

Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 include/libfdt.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/include/libfdt.h b/include/libfdt.h
index 74b1d149c2dd..fbbe58ceb3f1 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -440,6 +440,30 @@ int fdt_first_property_offset(const void *fdt, int nodeoffset);
  */
 int fdt_next_property_offset(const void *fdt, int offset);
 
+/**
+ * fdt_for_each_property - iterate over all properties of a node
+ * @property_offset:	property offset (int)
+ * @fdt:		FDT blob (const void *)
+ * @node:		node offset (int)
+ *
+ * This is actually a wrapper around a for loop and would be used like so:
+ *
+ *	fdt_for_each_property(fdt, node, property) {
+ *		...
+ *		use property
+ *		...
+ *	}
+ *
+ * Note that this is implemented as a macro and property is used as
+ * iterator in the loop. It should therefore be a locally allocated
+ * variable. The node variable on the other hand is never modified, so
+ * it can be constant or even a literal.
+ */
+#define fdt_for_each_property_offset(property, fdt, node)	\
+	for (property = fdt_first_property_offset(fdt, node);	\
+	     property >= 0;					\
+	     property = fdt_next_property_offset(fdt, property))
+
 /**
  * fdt_get_property_by_offset - retrieve the property at a given offset
  * @fdt: pointer to the device tree blob
-- 
2.9.0

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

* [U-Boot] [PATCH v4 06/13] libfdt: Add max phandle retrieval function
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: u-boot

Add a function to retrieve the highest phandle in a given device tree.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Reviewed-by: Stefan Agner <stefan@agner.ch>
Acked-by: Simon Glass <sjg@chromium.org>
---
 include/libfdt.h    | 13 +++++++++++++
 lib/libfdt/fdt_ro.c | 26 ++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/include/libfdt.h b/include/libfdt.h
index fbbe58ceb3f1..4643be5adf39 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -283,6 +283,19 @@ int fdt_move(const void *fdt, void *buf, int bufsize);
  */
 const char *fdt_string(const void *fdt, int stroffset);
 
+/**
+ * fdt_get_max_phandle - retrieves the highest phandle in a tree
+ * @fdt: pointer to the device tree blob
+ *
+ * fdt_get_max_phandle retrieves the highest phandle in the given
+ * device tree
+ *
+ * returns:
+ *      the highest phandle on success
+ *      0, if an error occurred
+ */
+uint32_t fdt_get_max_phandle(const void *fdt);
+
 /**
  * fdt_num_mem_rsv - retrieve the number of memory reserve map entries
  * @fdt: pointer to the device tree blob
diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
index 12214c2dc2b5..503150ef1dc5 100644
--- a/lib/libfdt/fdt_ro.c
+++ b/lib/libfdt/fdt_ro.c
@@ -47,6 +47,32 @@ static int _fdt_string_eq(const void *fdt, int stroffset,
 	return (strnlen(p, len + 1) == len) && (memcmp(p, s, len) == 0);
 }
 
+uint32_t fdt_get_max_phandle(const void *fdt)
+{
+	uint32_t max_phandle = 0;
+	int offset;
+
+	for (offset = fdt_next_node(fdt, -1, NULL);;
+	     offset = fdt_next_node(fdt, offset, NULL)) {
+		uint32_t phandle;
+
+		if (offset == -FDT_ERR_NOTFOUND)
+			return max_phandle;
+
+		if (offset < 0)
+			return 0;
+
+		phandle = fdt_get_phandle(fdt, offset);
+		if (phandle == (uint32_t)-1)
+			return 0;
+
+		if (phandle > max_phandle)
+			max_phandle = phandle;
+	}
+
+	return 0;
+}
+
 int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
 {
 	FDT_CHECK_HEADER(fdt);
-- 
2.9.0

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

* [PATCH v4 06/13] libfdt: Add max phandle retrieval function
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: Pantelis Antoniou, Simon Glass
  Cc: Boris Brezillon, Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner, David Gibson, Maxime Ripard

Add a function to retrieve the highest phandle in a given device tree.

Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Reviewed-by: Stefan Agner <stefan-XLVq0VzYD2Y@public.gmane.org>
Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 include/libfdt.h    | 13 +++++++++++++
 lib/libfdt/fdt_ro.c | 26 ++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/include/libfdt.h b/include/libfdt.h
index fbbe58ceb3f1..4643be5adf39 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -283,6 +283,19 @@ int fdt_move(const void *fdt, void *buf, int bufsize);
  */
 const char *fdt_string(const void *fdt, int stroffset);
 
+/**
+ * fdt_get_max_phandle - retrieves the highest phandle in a tree
+ * @fdt: pointer to the device tree blob
+ *
+ * fdt_get_max_phandle retrieves the highest phandle in the given
+ * device tree
+ *
+ * returns:
+ *      the highest phandle on success
+ *      0, if an error occurred
+ */
+uint32_t fdt_get_max_phandle(const void *fdt);
+
 /**
  * fdt_num_mem_rsv - retrieve the number of memory reserve map entries
  * @fdt: pointer to the device tree blob
diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
index 12214c2dc2b5..503150ef1dc5 100644
--- a/lib/libfdt/fdt_ro.c
+++ b/lib/libfdt/fdt_ro.c
@@ -47,6 +47,32 @@ static int _fdt_string_eq(const void *fdt, int stroffset,
 	return (strnlen(p, len + 1) == len) && (memcmp(p, s, len) == 0);
 }
 
+uint32_t fdt_get_max_phandle(const void *fdt)
+{
+	uint32_t max_phandle = 0;
+	int offset;
+
+	for (offset = fdt_next_node(fdt, -1, NULL);;
+	     offset = fdt_next_node(fdt, offset, NULL)) {
+		uint32_t phandle;
+
+		if (offset == -FDT_ERR_NOTFOUND)
+			return max_phandle;
+
+		if (offset < 0)
+			return 0;
+
+		phandle = fdt_get_phandle(fdt, offset);
+		if (phandle == (uint32_t)-1)
+			return 0;
+
+		if (phandle > max_phandle)
+			max_phandle = phandle;
+	}
+
+	return 0;
+}
+
 int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
 {
 	FDT_CHECK_HEADER(fdt);
-- 
2.9.0

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

* [U-Boot] [PATCH v4 07/13] libfdt: Fix separator spelling
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: u-boot

The function fdt_path_next_seperator had an obvious mispell. Fix it.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 lib/libfdt/fdt_ro.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
index 503150ef1dc5..6b737b211d2e 100644
--- a/lib/libfdt/fdt_ro.c
+++ b/lib/libfdt/fdt_ro.c
@@ -140,12 +140,12 @@ int fdt_subnode_offset(const void *fdt, int parentoffset,
 }
 
 /*
- * Find the next of path seperator, note we need to search for both '/' and ':'
+ * Find the next of path separator, note we need to search for both '/' and ':'
  * and then take the first one so that we do the right thing for e.g.
  * "foo/bar:option" and "bar:option/otheroption", both of which happen, so
  * first searching for either ':' or '/' does not work.
  */
-static const char *fdt_path_next_seperator(const char *path)
+static const char *fdt_path_next_separator(const char *path)
 {
 	const char *sep1 = strchr(path, '/');
 	const char *sep2 = strchr(path, ':');
@@ -168,7 +168,7 @@ int fdt_path_offset(const void *fdt, const char *path)
 
 	/* see if we have an alias */
 	if (*path != '/') {
-		const char *q = fdt_path_next_seperator(path);
+		const char *q = fdt_path_next_separator(path);
 
 		if (!q)
 			q = end;
@@ -188,7 +188,7 @@ int fdt_path_offset(const void *fdt, const char *path)
 			p++;
 		if (*p == '\0' || *p == ':')
 			return offset;
-		q = fdt_path_next_seperator(p);
+		q = fdt_path_next_separator(p);
 		if (!q)
 			q = end;
 
-- 
2.9.0

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

* [PATCH v4 07/13] libfdt: Fix separator spelling
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: Pantelis Antoniou, Simon Glass
  Cc: Boris Brezillon, Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner, David Gibson, Maxime Ripard

The function fdt_path_next_seperator had an obvious mispell. Fix it.

Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 lib/libfdt/fdt_ro.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
index 503150ef1dc5..6b737b211d2e 100644
--- a/lib/libfdt/fdt_ro.c
+++ b/lib/libfdt/fdt_ro.c
@@ -140,12 +140,12 @@ int fdt_subnode_offset(const void *fdt, int parentoffset,
 }
 
 /*
- * Find the next of path seperator, note we need to search for both '/' and ':'
+ * Find the next of path separator, note we need to search for both '/' and ':'
  * and then take the first one so that we do the right thing for e.g.
  * "foo/bar:option" and "bar:option/otheroption", both of which happen, so
  * first searching for either ':' or '/' does not work.
  */
-static const char *fdt_path_next_seperator(const char *path)
+static const char *fdt_path_next_separator(const char *path)
 {
 	const char *sep1 = strchr(path, '/');
 	const char *sep2 = strchr(path, ':');
@@ -168,7 +168,7 @@ int fdt_path_offset(const void *fdt, const char *path)
 
 	/* see if we have an alias */
 	if (*path != '/') {
-		const char *q = fdt_path_next_seperator(path);
+		const char *q = fdt_path_next_separator(path);
 
 		if (!q)
 			q = end;
@@ -188,7 +188,7 @@ int fdt_path_offset(const void *fdt, const char *path)
 			p++;
 		if (*p == '\0' || *p == ':')
 			return offset;
-		q = fdt_path_next_seperator(p);
+		q = fdt_path_next_separator(p);
 		if (!q)
 			q = end;
 
-- 
2.9.0

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

* [U-Boot] [PATCH v4 08/13] libfdt: Add fdt_path_offset_namelen
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: u-boot

Add a namelen variant of fdt_path_offset to retrieve the node offset using
only a fixed number of characters.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 include/libfdt.h    | 16 +++++++++++++++-
 lib/libfdt/fdt_ro.c | 18 ++++++++++--------
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/include/libfdt.h b/include/libfdt.h
index 4643be5adf39..f13b01f08f71 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -365,6 +365,17 @@ int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
  */
 int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
 
+/**
+ * fdt_path_offset_namelen - find a tree node based on substring
+ * @fdt: pointer to the device tree blob
+ * @path: full path of the node to locate
+ * @namelen: number of characters of name to consider
+ *
+ * Identical to fdt_path_offset(), but only examine the first
+ * namelen characters of path for matching the node path.
+ */
+int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
+
 /**
  * fdt_path_offset - find a tree node by its full path
  * @fdt: pointer to the device tree blob
@@ -387,7 +398,10 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
  *	-FDT_ERR_BADSTRUCTURE,
  *	-FDT_ERR_TRUNCATED, standard meanings.
  */
-int fdt_path_offset(const void *fdt, const char *path);
+static inline int fdt_path_offset(const void *fdt, const char *path)
+{
+	return fdt_path_offset_namelen(fdt, path, strlen(path));
+}
 
 /**
  * fdt_get_name - retrieve the name of a given node
diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
index 6b737b211d2e..9cc98db6e2bf 100644
--- a/lib/libfdt/fdt_ro.c
+++ b/lib/libfdt/fdt_ro.c
@@ -145,10 +145,10 @@ int fdt_subnode_offset(const void *fdt, int parentoffset,
  * "foo/bar:option" and "bar:option/otheroption", both of which happen, so
  * first searching for either ':' or '/' does not work.
  */
-static const char *fdt_path_next_separator(const char *path)
+static const char *fdt_path_next_separator(const char *path, int len)
 {
-	const char *sep1 = strchr(path, '/');
-	const char *sep2 = strchr(path, ':');
+	const void *sep1 = memchr(path, '/', len);
+	const void *sep2 = memchr(path, ':', len);
 
 	if (sep1 && sep2)
 		return (sep1 < sep2) ? sep1 : sep2;
@@ -158,9 +158,9 @@ static const char *fdt_path_next_separator(const char *path)
 		return sep2;
 }
 
-int fdt_path_offset(const void *fdt, const char *path)
+int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen)
 {
-	const char *end = path + strlen(path);
+	const char *end = path + namelen;
 	const char *p = path;
 	int offset = 0;
 
@@ -168,7 +168,7 @@ int fdt_path_offset(const void *fdt, const char *path)
 
 	/* see if we have an alias */
 	if (*path != '/') {
-		const char *q = fdt_path_next_separator(path);
+		const char *q = fdt_path_next_separator(path, namelen);
 
 		if (!q)
 			q = end;
@@ -181,14 +181,16 @@ int fdt_path_offset(const void *fdt, const char *path)
 		p = q;
 	}
 
-	while (*p) {
+	while (*p && (p < end)) {
 		const char *q;
 
 		while (*p == '/')
 			p++;
+
 		if (*p == '\0' || *p == ':')
 			return offset;
-		q = fdt_path_next_separator(p);
+
+		q = fdt_path_next_separator(p, end - p);
 		if (!q)
 			q = end;
 
-- 
2.9.0

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

* [PATCH v4 08/13] libfdt: Add fdt_path_offset_namelen
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: Pantelis Antoniou, Simon Glass
  Cc: Boris Brezillon, Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner, David Gibson, Maxime Ripard

Add a namelen variant of fdt_path_offset to retrieve the node offset using
only a fixed number of characters.

Reviewed-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 include/libfdt.h    | 16 +++++++++++++++-
 lib/libfdt/fdt_ro.c | 18 ++++++++++--------
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/include/libfdt.h b/include/libfdt.h
index 4643be5adf39..f13b01f08f71 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -365,6 +365,17 @@ int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
  */
 int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
 
+/**
+ * fdt_path_offset_namelen - find a tree node based on substring
+ * @fdt: pointer to the device tree blob
+ * @path: full path of the node to locate
+ * @namelen: number of characters of name to consider
+ *
+ * Identical to fdt_path_offset(), but only examine the first
+ * namelen characters of path for matching the node path.
+ */
+int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
+
 /**
  * fdt_path_offset - find a tree node by its full path
  * @fdt: pointer to the device tree blob
@@ -387,7 +398,10 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
  *	-FDT_ERR_BADSTRUCTURE,
  *	-FDT_ERR_TRUNCATED, standard meanings.
  */
-int fdt_path_offset(const void *fdt, const char *path);
+static inline int fdt_path_offset(const void *fdt, const char *path)
+{
+	return fdt_path_offset_namelen(fdt, path, strlen(path));
+}
 
 /**
  * fdt_get_name - retrieve the name of a given node
diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
index 6b737b211d2e..9cc98db6e2bf 100644
--- a/lib/libfdt/fdt_ro.c
+++ b/lib/libfdt/fdt_ro.c
@@ -145,10 +145,10 @@ int fdt_subnode_offset(const void *fdt, int parentoffset,
  * "foo/bar:option" and "bar:option/otheroption", both of which happen, so
  * first searching for either ':' or '/' does not work.
  */
-static const char *fdt_path_next_separator(const char *path)
+static const char *fdt_path_next_separator(const char *path, int len)
 {
-	const char *sep1 = strchr(path, '/');
-	const char *sep2 = strchr(path, ':');
+	const void *sep1 = memchr(path, '/', len);
+	const void *sep2 = memchr(path, ':', len);
 
 	if (sep1 && sep2)
 		return (sep1 < sep2) ? sep1 : sep2;
@@ -158,9 +158,9 @@ static const char *fdt_path_next_separator(const char *path)
 		return sep2;
 }
 
-int fdt_path_offset(const void *fdt, const char *path)
+int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen)
 {
-	const char *end = path + strlen(path);
+	const char *end = path + namelen;
 	const char *p = path;
 	int offset = 0;
 
@@ -168,7 +168,7 @@ int fdt_path_offset(const void *fdt, const char *path)
 
 	/* see if we have an alias */
 	if (*path != '/') {
-		const char *q = fdt_path_next_separator(path);
+		const char *q = fdt_path_next_separator(path, namelen);
 
 		if (!q)
 			q = end;
@@ -181,14 +181,16 @@ int fdt_path_offset(const void *fdt, const char *path)
 		p = q;
 	}
 
-	while (*p) {
+	while (*p && (p < end)) {
 		const char *q;
 
 		while (*p == '/')
 			p++;
+
 		if (*p == '\0' || *p == ':')
 			return offset;
-		q = fdt_path_next_separator(p);
+
+		q = fdt_path_next_separator(p, end - p);
 		if (!q)
 			q = end;
 
-- 
2.9.0

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

* [U-Boot] [PATCH v4 09/13] libfdt: Add fdt_getprop_namelen_w
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: u-boot

Add a function to retrieve a writeable property only by the first
characters of its name.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 include/libfdt.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/libfdt.h b/include/libfdt.h
index f13b01f08f71..a55d2d0d8c7b 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -619,6 +619,13 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
  */
 const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
 				const char *name, int namelen, int *lenp);
+static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
+					  const char *name, int namelen,
+					  int *lenp)
+{
+	return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
+						      namelen, lenp);
+}
 
 /**
  * fdt_getprop - retrieve the value of a given property
-- 
2.9.0

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

* [PATCH v4 09/13] libfdt: Add fdt_getprop_namelen_w
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: Pantelis Antoniou, Simon Glass
  Cc: Boris Brezillon, Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner, David Gibson, Maxime Ripard

Add a function to retrieve a writeable property only by the first
characters of its name.

Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 include/libfdt.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/libfdt.h b/include/libfdt.h
index f13b01f08f71..a55d2d0d8c7b 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -619,6 +619,13 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
  */
 const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
 				const char *name, int namelen, int *lenp);
+static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
+					  const char *name, int namelen,
+					  int *lenp)
+{
+	return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
+						      namelen, lenp);
+}
 
 /**
  * fdt_getprop - retrieve the value of a given property
-- 
2.9.0

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

* [U-Boot] [PATCH v4 10/13] libfdt: Add fdt_setprop_inplace_namelen_partial
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: u-boot

Add a function to modify inplace only a portion of a property..

This is especially useful when the property is an array of values, and you
want to update one of them without changing the DT size.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Simon Glass <sjg@chromium.org>
---
 include/libfdt.h     | 21 +++++++++++++++++++++
 lib/libfdt/fdt_wip.c | 29 +++++++++++++++++++++++++----
 2 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/include/libfdt.h b/include/libfdt.h
index a55d2d0d8c7b..4c56711c7132 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -1053,6 +1053,27 @@ int fdt_size_cells(const void *fdt, int nodeoffset);
 /* Write-in-place functions                                           */
 /**********************************************************************/
 
+/**
+ * fdt_setprop_inplace_namelen_partial - change a property's value,
+ *                                       but not its size
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to change
+ * @namelen: number of characters of name to consider
+ * @index: index of the property to change in the array
+ * @val: pointer to data to replace the property value with
+ * @len: length of the property value
+ *
+ * Identical to fdt_setprop_inplace(), but modifies the given property
+ * starting from the given index, and using only the first characters
+ * of the name. It is useful when you want to manipulate only one value of
+ * an array and you have a string that doesn't end with \0.
+ */
+int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
+					const char *name, int namelen,
+					uint32_t index, const void *val,
+					int len);
+
 /**
  * fdt_setprop_inplace - change a property's value, but not its size
  * @fdt: pointer to the device tree blob
diff --git a/lib/libfdt/fdt_wip.c b/lib/libfdt/fdt_wip.c
index 9fe988655fe3..216c51287d09 100644
--- a/lib/libfdt/fdt_wip.c
+++ b/lib/libfdt/fdt_wip.c
@@ -14,21 +14,42 @@
 
 #include "libfdt_internal.h"
 
+int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
+					const char *name, int namelen,
+					uint32_t index, const void *val,
+					int len)
+{
+	void *propval;
+	int proplen;
+
+	propval = fdt_getprop_namelen_w(fdt, nodeoffset, name, namelen,
+					&proplen);
+	if (!propval)
+		return proplen;
+
+	if (proplen < (len + index))
+		return -FDT_ERR_NOSPACE;
+
+	memcpy(propval + index, val, len);
+	return 0;
+}
+
 int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
 			const void *val, int len)
 {
-	void *propval;
+	const void *propval;
 	int proplen;
 
-	propval = fdt_getprop_w(fdt, nodeoffset, name, &proplen);
+	propval = fdt_getprop(fdt, nodeoffset, name, &proplen);
 	if (!propval)
 		return proplen;
 
 	if (proplen != len)
 		return -FDT_ERR_NOSPACE;
 
-	memcpy(propval, val, len);
-	return 0;
+	return fdt_setprop_inplace_namelen_partial(fdt, nodeoffset, name,
+						   strlen(name), 0,
+						   val, len);
 }
 
 static void _fdt_nop_region(void *start, int len)
-- 
2.9.0

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

* [PATCH v4 10/13] libfdt: Add fdt_setprop_inplace_namelen_partial
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: Pantelis Antoniou, Simon Glass
  Cc: Boris Brezillon, Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner, David Gibson, Maxime Ripard

Add a function to modify inplace only a portion of a property..

This is especially useful when the property is an array of values, and you
want to update one of them without changing the DT size.

Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 include/libfdt.h     | 21 +++++++++++++++++++++
 lib/libfdt/fdt_wip.c | 29 +++++++++++++++++++++++++----
 2 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/include/libfdt.h b/include/libfdt.h
index a55d2d0d8c7b..4c56711c7132 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -1053,6 +1053,27 @@ int fdt_size_cells(const void *fdt, int nodeoffset);
 /* Write-in-place functions                                           */
 /**********************************************************************/
 
+/**
+ * fdt_setprop_inplace_namelen_partial - change a property's value,
+ *                                       but not its size
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to change
+ * @namelen: number of characters of name to consider
+ * @index: index of the property to change in the array
+ * @val: pointer to data to replace the property value with
+ * @len: length of the property value
+ *
+ * Identical to fdt_setprop_inplace(), but modifies the given property
+ * starting from the given index, and using only the first characters
+ * of the name. It is useful when you want to manipulate only one value of
+ * an array and you have a string that doesn't end with \0.
+ */
+int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
+					const char *name, int namelen,
+					uint32_t index, const void *val,
+					int len);
+
 /**
  * fdt_setprop_inplace - change a property's value, but not its size
  * @fdt: pointer to the device tree blob
diff --git a/lib/libfdt/fdt_wip.c b/lib/libfdt/fdt_wip.c
index 9fe988655fe3..216c51287d09 100644
--- a/lib/libfdt/fdt_wip.c
+++ b/lib/libfdt/fdt_wip.c
@@ -14,21 +14,42 @@
 
 #include "libfdt_internal.h"
 
+int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
+					const char *name, int namelen,
+					uint32_t index, const void *val,
+					int len)
+{
+	void *propval;
+	int proplen;
+
+	propval = fdt_getprop_namelen_w(fdt, nodeoffset, name, namelen,
+					&proplen);
+	if (!propval)
+		return proplen;
+
+	if (proplen < (len + index))
+		return -FDT_ERR_NOSPACE;
+
+	memcpy(propval + index, val, len);
+	return 0;
+}
+
 int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
 			const void *val, int len)
 {
-	void *propval;
+	const void *propval;
 	int proplen;
 
-	propval = fdt_getprop_w(fdt, nodeoffset, name, &proplen);
+	propval = fdt_getprop(fdt, nodeoffset, name, &proplen);
 	if (!propval)
 		return proplen;
 
 	if (proplen != len)
 		return -FDT_ERR_NOSPACE;
 
-	memcpy(propval, val, len);
-	return 0;
+	return fdt_setprop_inplace_namelen_partial(fdt, nodeoffset, name,
+						   strlen(name), 0,
+						   val, len);
 }
 
 static void _fdt_nop_region(void *start, int len)
-- 
2.9.0

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

* [U-Boot] [PATCH v4 11/13] libfdt: Add overlay application function
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: u-boot

The device tree overlays are a good way to deal with user-modifyable
boards or boards with some kind of an expansion mechanism where we can
easily plug new board in (like the BBB, the Raspberry Pi or the CHIP).

Add a new function to merge overlays with a base device tree.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 include/libfdt.h         |  30 ++++
 lib/Kconfig              |   5 +
 lib/libfdt/Makefile      |   2 +
 lib/libfdt/fdt_overlay.c | 405 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 442 insertions(+)
 create mode 100644 lib/libfdt/fdt_overlay.c

diff --git a/include/libfdt.h b/include/libfdt.h
index 4c56711c7132..b6a400a7a823 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -1740,6 +1740,36 @@ int fdt_add_subnode(void *fdt, int parentoffset, const char *name);
  */
 int fdt_del_node(void *fdt, int nodeoffset);
 
+/**
+ * fdt_overlay_apply - Applies a DT overlay on a base DT
+ * @fdt: pointer to the base device tree blob
+ * @fdto: pointer to the device tree overlay blob
+ *
+ * fdt_overlay_apply() will apply the given device tree overlay on the
+ * given base device tree.
+ *
+ * Expect the base device tree to be modified, even if the function
+ * returns an error.
+ *
+ * returns:
+ *	0, on success
+ *	-FDT_ERR_NOSPACE, there's not enough space in the base device tree
+ *	-FDT_ERR_NOTFOUND, the overlay points to some inexistant nodes or
+ *		properties in the base DT
+ *	-FDT_ERR_BADPHANDLE, the phandles in the overlay do not have the right
+ *		magic
+ *	-FDT_ERR_INTERNAL,
+ *	-FDT_ERR_BADLAYOUT,
+ *	-FDT_ERR_BADMAGIC,
+ *	-FDT_ERR_BADOFFSET,
+ *	-FDT_ERR_BADPATH,
+ *	-FDT_ERR_BADVERSION,
+ *	-FDT_ERR_BADSTRUCTURE,
+ *	-FDT_ERR_BADSTATE,
+ *	-FDT_ERR_TRUNCATED, standard meanings
+ */
+int fdt_overlay_apply(void *fdt, void *fdto);
+
 /**********************************************************************/
 /* Debugging / informational functions                                */
 /**********************************************************************/
diff --git a/lib/Kconfig b/lib/Kconfig
index 02ca4058d37e..16ff01a2cd37 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -139,6 +139,11 @@ config OF_LIBFDT
 	  particular compatible nodes. The library operates on a flattened
 	  version of the device tree.
 
+config OF_LIBFDT_OVERLAY
+	bool "Enable the FDT library overlay support"
+	help
+	  This enables the FDT library (libfdt) overlay support.
+
 config SPL_OF_LIBFDT
 	bool "Enable the FDT library for SPL"
 	default y if SPL_OF_CONTROL
diff --git a/lib/libfdt/Makefile b/lib/libfdt/Makefile
index 8b86c15904cb..6ef8290f4e09 100644
--- a/lib/libfdt/Makefile
+++ b/lib/libfdt/Makefile
@@ -15,3 +15,5 @@ obj-y += \
 	fdt_empty_tree.o \
 	fdt_addresses.o \
 	fdt_region.o
+
+obj-$(CONFIG_OF_LIBFDT_OVERLAY) += fdt_overlay.o
diff --git a/lib/libfdt/fdt_overlay.c b/lib/libfdt/fdt_overlay.c
new file mode 100644
index 000000000000..c45e8b25fb06
--- /dev/null
+++ b/lib/libfdt/fdt_overlay.c
@@ -0,0 +1,405 @@
+#include "libfdt_env.h"
+
+#include <fdt.h>
+#include <libfdt.h>
+
+#include "libfdt_internal.h"
+
+static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
+{
+	const uint32_t *val;
+	int len;
+
+	val = fdt_getprop(fdto, fragment, "target", &len);
+	if (!val)
+		return 0;
+
+	if ((*val == 0xffffffff) || (len != sizeof(*val)))
+		return 0xffffffff;
+
+	return fdt32_to_cpu(*val);
+}
+
+static int overlay_get_target(const void *fdt, const void *fdto,
+			      int fragment)
+{
+	uint32_t phandle;
+	const char *path;
+
+	/* Try first to do a phandle based lookup */
+	phandle = overlay_get_target_phandle(fdto, fragment);
+	if (phandle == -1)
+		return -FDT_ERR_BADPHANDLE;
+
+	if (phandle)
+		return fdt_node_offset_by_phandle(fdt, phandle);
+
+	/* And then a path based lookup */
+	path = fdt_getprop(fdto, fragment, "target-path", NULL);
+	if (!path)
+		return -FDT_ERR_NOTFOUND;
+
+	return fdt_path_offset(fdt, path);
+}
+
+static int overlay_phandle_add_offset(void *fdt, int node,
+				      const char *name, uint32_t delta)
+{
+	const uint32_t *val;
+	uint32_t adj_val;
+	int len;
+
+	val = fdt_getprop(fdt, node, name, &len);
+	if (!val)
+		return len;
+
+	if (len != sizeof(*val))
+		return -FDT_ERR_BADSTRUCTURE;
+
+	adj_val = fdt32_to_cpu(*val);
+	if ((adj_val + delta) < adj_val)
+		return -FDT_ERR_BADPHANDLE;
+
+	adj_val += delta;
+	return fdt_setprop_inplace_u32(fdt, node, name, adj_val);
+}
+
+static int overlay_adjust_node_phandles(void *fdto, int node,
+					uint32_t delta)
+{
+	bool found = false;
+	int child;
+	int ret;
+
+	ret = overlay_phandle_add_offset(fdto, node, "phandle", delta);
+	if (ret && ret != -FDT_ERR_NOTFOUND)
+		return ret;
+
+	if (!ret)
+		found = true;
+
+	ret = overlay_phandle_add_offset(fdto, node, "linux,phandle", delta);
+	if (ret && ret != -FDT_ERR_NOTFOUND)
+		return ret;
+
+	/*
+	 * If neither phandle nor linux,phandle have been found return
+	 * an error.
+	 */
+	if (!found && !ret)
+		return ret;
+
+	fdt_for_each_subnode(fdto, child, node)
+		overlay_adjust_node_phandles(fdto, child, delta);
+
+	return 0;
+}
+
+static int overlay_adjust_local_phandles(void *fdto, uint32_t delta)
+{
+	/*
+	 * Start adjusting the phandles from the overlay root
+	 */
+	return overlay_adjust_node_phandles(fdto, 0, delta);
+}
+
+static int overlay_update_local_node_references(void *fdto,
+						int tree_node,
+						int fixup_node,
+						uint32_t delta)
+{
+	int fixup_prop;
+	int fixup_child;
+	int ret;
+
+	fdt_for_each_property_offset(fixup_prop, fdto, fixup_node) {
+		const uint32_t *val = NULL;
+		uint32_t adj_val, index;
+		const char *name;
+		int fixup_len;
+		int tree_len;
+
+		val = fdt_getprop_by_offset(fdto, fixup_prop,
+					    &name, &fixup_len);
+		if (!val)
+			return fixup_len;
+		index = fdt32_to_cpu(*val);
+
+		val = fdt_getprop(fdto, tree_node, name, &tree_len);
+		if (!val)
+			return tree_len;
+
+		/*
+		 * The index can be unaligned.
+		 *
+		 * Use a memcpy for the architectures that do not
+		 * support unaligned accesses.
+		 */
+		memcpy(&adj_val, (unsigned char *)val + index,
+		       sizeof(uint32_t));
+
+		adj_val = fdt32_to_cpu(adj_val);
+		adj_val += delta;
+		adj_val = cpu_to_fdt32(adj_val);
+
+		ret = fdt_setprop_inplace_namelen_by_index(fdto, tree_node,
+							   name, strlen(name),
+							   index, &adj_val,
+							   sizeof(adj_val));
+		if (ret)
+			return ret;
+	}
+
+	fdt_for_each_subnode(fdto, fixup_child, fixup_node) {
+		const char *fixup_child_name = fdt_get_name(fdto, fixup_child,
+							    NULL);
+		int tree_child;
+
+		tree_child = fdt_subnode_offset(fdto, tree_node,
+						fixup_child_name);
+		if (tree_child < 0)
+			return tree_child;
+
+		ret = overlay_update_local_node_references(fdto,
+							   tree_child,
+							   fixup_child,
+							   delta);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
+static int overlay_update_local_references(void *dto, uint32_t delta)
+{
+	int fixups;
+
+	fixups = fdt_path_offset(dto, "/__local_fixups__");
+	if (fixups < 0) {
+		/* There's no local phandles to adjust, bail out */
+		if (fixups == -FDT_ERR_NOTFOUND)
+			return 0;
+
+		return fixups;
+	}
+
+	/*
+	 * Update our local references from the root of the tree
+	 */
+	return overlay_update_local_node_references(dto, 0, fixups,
+						    delta);
+}
+
+static int overlay_fixup_one_phandle(void *fdt, void *fdto,
+				     int symbols_off,
+				     const char *path, uint32_t path_len,
+				     const char *name, uint32_t name_len,
+				     int index, const char *label)
+{
+	const char *symbol_path;
+	uint32_t phandle;
+	int symbol_off, fixup_off;
+	int prop_len;
+
+	symbol_path = fdt_getprop(fdt, symbols_off, label,
+				  &prop_len);
+	if (!symbol_path)
+		return -FDT_ERR_NOTFOUND;
+
+	symbol_off = fdt_path_offset(fdt, symbol_path);
+	if (symbol_off < 0)
+		return symbol_off;
+
+	phandle = fdt_get_phandle(fdt, symbol_off);
+	if (!phandle)
+		return -FDT_ERR_NOTFOUND;
+
+	fixup_off = fdt_path_offset_namelen(fdto, path, path_len);
+	if (fixup_off < 0)
+		return fixup_off;
+
+	phandle = cpu_to_fdt32(phandle);
+	return fdt_setprop_inplace_namelen_by_index(fdto, fixup_off,
+						    name, name_len, index,
+						    &phandle, sizeof(phandle));
+};
+
+static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
+				 int property)
+{
+	const char *value;
+	const char *label;
+	int len;
+
+	value = fdt_getprop_by_offset(fdto, property,
+				      &label, &len);
+	if (!value)
+		return len;
+
+	do {
+		const char *prop_string = value;
+		const char *path, *name;
+		uint32_t prop_len = strlen(value);
+		uint32_t path_len, name_len;
+		char *sep, *endptr;
+		int index;
+		int ret;
+
+		path = prop_string;
+		sep = memchr(prop_string, ':', prop_len);
+		if (*sep != ':')
+			return -FDT_ERR_BADSTRUCTURE;
+		path_len = sep - path;
+
+		name = sep + 1;
+		sep = memchr(name, ':', prop_len);
+		if (*sep != ':')
+			return -FDT_ERR_BADSTRUCTURE;
+		name_len = sep - name;
+
+		index = strtoul(sep + 1, &endptr, 10);
+		if ((*endptr != '\0') || (endptr <= (sep + 1)))
+			return -FDT_ERR_BADSTRUCTURE;
+
+		len -= prop_len + 1;
+		value += prop_len + 1;
+
+		ret = overlay_fixup_one_phandle(fdt, fdto, symbols_off,
+						path, path_len, name, name_len,
+						index, label);
+		if (ret)
+			return ret;
+	} while (len > 0);
+
+	return 0;
+}
+
+static int overlay_fixup_phandles(void *dt, void *dto)
+{
+	int fixups_off, symbols_off;
+	int property;
+
+	symbols_off = fdt_path_offset(dt, "/__symbols__");
+	fixups_off = fdt_path_offset(dto, "/__fixups__");
+
+	fdt_for_each_property_offset(property, dto, fixups_off)
+		overlay_fixup_phandle(dt, dto, symbols_off, property);
+
+	return 0;
+}
+
+static int apply_overlay_node(void *dt, int target,
+			      void *dto, int fragment)
+{
+	int property;
+	int node;
+
+	fdt_for_each_property_offset(property, dto, fragment) {
+		const char *name;
+		const void *prop;
+		int prop_len;
+		int ret;
+
+		prop = fdt_getprop_by_offset(dto, property, &name,
+					     &prop_len);
+		if (prop_len == -FDT_ERR_NOTFOUND)
+			return -FDT_ERR_INTERNAL;
+		if (prop_len < 0)
+			return prop_len;
+
+		ret = fdt_setprop(dt, target, name, prop, prop_len);
+		if (ret)
+			return ret;
+	}
+
+	fdt_for_each_subnode(dto, node, fragment) {
+		const char *name = fdt_get_name(dto, node, NULL);
+		int nnode;
+		int ret;
+
+		nnode = fdt_add_subnode(dt, target, name);
+		if (nnode == -FDT_ERR_EXISTS)
+			nnode = fdt_subnode_offset(dt, target, name);
+
+		if (nnode < 0)
+			return nnode;
+
+		ret = apply_overlay_node(dt, nnode, dto, node);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
+static int overlay_merge(void *dt, void *dto)
+{
+	int fragment;
+
+	fdt_for_each_subnode(dto, fragment, 0) {
+		int overlay;
+		int target;
+		int ret;
+
+		target = overlay_get_target(dt, dto, fragment);
+		if (target < 0)
+			continue;
+
+		overlay = fdt_subnode_offset(dto, fragment, "__overlay__");
+		if (overlay < 0)
+			return overlay;
+
+		ret = apply_overlay_node(dt, target, dto, overlay);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
+int fdt_overlay_apply(void *fdt, void *fdto)
+{
+	uint32_t delta = fdt_get_max_phandle(fdt) + 1;
+	int ret;
+
+	FDT_CHECK_HEADER(fdt);
+	FDT_CHECK_HEADER(fdto);
+
+	ret = overlay_adjust_local_phandles(fdto, delta);
+	if (ret)
+		goto err;
+
+	ret = overlay_update_local_references(fdto, delta);
+	if (ret)
+		goto err;
+
+	ret = overlay_fixup_phandles(fdt, fdto);
+	if (ret)
+		goto err;
+
+	ret = overlay_merge(fdt, fdto);
+	if (ret)
+		goto err;
+
+	/*
+	 * The overlay has been damaged, erase its magic.
+	 */
+	fdt_set_magic(fdto, ~0);
+
+	return 0;
+
+err:
+	/*
+	 * The overlay might have been damaged, erase its magic.
+	 */
+	fdt_set_magic(fdto, ~0);
+
+	/*
+	 * The base device tree might have been damaged, erase its
+	 * magic.
+	 */
+	fdt_set_magic(fdt, ~0);
+
+	return ret;
+}
-- 
2.9.0

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

* [PATCH v4 11/13] libfdt: Add overlay application function
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: Pantelis Antoniou, Simon Glass
  Cc: Boris Brezillon, Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner, David Gibson, Maxime Ripard

The device tree overlays are a good way to deal with user-modifyable
boards or boards with some kind of an expansion mechanism where we can
easily plug new board in (like the BBB, the Raspberry Pi or the CHIP).

Add a new function to merge overlays with a base device tree.

Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 include/libfdt.h         |  30 ++++
 lib/Kconfig              |   5 +
 lib/libfdt/Makefile      |   2 +
 lib/libfdt/fdt_overlay.c | 405 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 442 insertions(+)
 create mode 100644 lib/libfdt/fdt_overlay.c

diff --git a/include/libfdt.h b/include/libfdt.h
index 4c56711c7132..b6a400a7a823 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -1740,6 +1740,36 @@ int fdt_add_subnode(void *fdt, int parentoffset, const char *name);
  */
 int fdt_del_node(void *fdt, int nodeoffset);
 
+/**
+ * fdt_overlay_apply - Applies a DT overlay on a base DT
+ * @fdt: pointer to the base device tree blob
+ * @fdto: pointer to the device tree overlay blob
+ *
+ * fdt_overlay_apply() will apply the given device tree overlay on the
+ * given base device tree.
+ *
+ * Expect the base device tree to be modified, even if the function
+ * returns an error.
+ *
+ * returns:
+ *	0, on success
+ *	-FDT_ERR_NOSPACE, there's not enough space in the base device tree
+ *	-FDT_ERR_NOTFOUND, the overlay points to some inexistant nodes or
+ *		properties in the base DT
+ *	-FDT_ERR_BADPHANDLE, the phandles in the overlay do not have the right
+ *		magic
+ *	-FDT_ERR_INTERNAL,
+ *	-FDT_ERR_BADLAYOUT,
+ *	-FDT_ERR_BADMAGIC,
+ *	-FDT_ERR_BADOFFSET,
+ *	-FDT_ERR_BADPATH,
+ *	-FDT_ERR_BADVERSION,
+ *	-FDT_ERR_BADSTRUCTURE,
+ *	-FDT_ERR_BADSTATE,
+ *	-FDT_ERR_TRUNCATED, standard meanings
+ */
+int fdt_overlay_apply(void *fdt, void *fdto);
+
 /**********************************************************************/
 /* Debugging / informational functions                                */
 /**********************************************************************/
diff --git a/lib/Kconfig b/lib/Kconfig
index 02ca4058d37e..16ff01a2cd37 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -139,6 +139,11 @@ config OF_LIBFDT
 	  particular compatible nodes. The library operates on a flattened
 	  version of the device tree.
 
+config OF_LIBFDT_OVERLAY
+	bool "Enable the FDT library overlay support"
+	help
+	  This enables the FDT library (libfdt) overlay support.
+
 config SPL_OF_LIBFDT
 	bool "Enable the FDT library for SPL"
 	default y if SPL_OF_CONTROL
diff --git a/lib/libfdt/Makefile b/lib/libfdt/Makefile
index 8b86c15904cb..6ef8290f4e09 100644
--- a/lib/libfdt/Makefile
+++ b/lib/libfdt/Makefile
@@ -15,3 +15,5 @@ obj-y += \
 	fdt_empty_tree.o \
 	fdt_addresses.o \
 	fdt_region.o
+
+obj-$(CONFIG_OF_LIBFDT_OVERLAY) += fdt_overlay.o
diff --git a/lib/libfdt/fdt_overlay.c b/lib/libfdt/fdt_overlay.c
new file mode 100644
index 000000000000..c45e8b25fb06
--- /dev/null
+++ b/lib/libfdt/fdt_overlay.c
@@ -0,0 +1,405 @@
+#include "libfdt_env.h"
+
+#include <fdt.h>
+#include <libfdt.h>
+
+#include "libfdt_internal.h"
+
+static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
+{
+	const uint32_t *val;
+	int len;
+
+	val = fdt_getprop(fdto, fragment, "target", &len);
+	if (!val)
+		return 0;
+
+	if ((*val == 0xffffffff) || (len != sizeof(*val)))
+		return 0xffffffff;
+
+	return fdt32_to_cpu(*val);
+}
+
+static int overlay_get_target(const void *fdt, const void *fdto,
+			      int fragment)
+{
+	uint32_t phandle;
+	const char *path;
+
+	/* Try first to do a phandle based lookup */
+	phandle = overlay_get_target_phandle(fdto, fragment);
+	if (phandle == -1)
+		return -FDT_ERR_BADPHANDLE;
+
+	if (phandle)
+		return fdt_node_offset_by_phandle(fdt, phandle);
+
+	/* And then a path based lookup */
+	path = fdt_getprop(fdto, fragment, "target-path", NULL);
+	if (!path)
+		return -FDT_ERR_NOTFOUND;
+
+	return fdt_path_offset(fdt, path);
+}
+
+static int overlay_phandle_add_offset(void *fdt, int node,
+				      const char *name, uint32_t delta)
+{
+	const uint32_t *val;
+	uint32_t adj_val;
+	int len;
+
+	val = fdt_getprop(fdt, node, name, &len);
+	if (!val)
+		return len;
+
+	if (len != sizeof(*val))
+		return -FDT_ERR_BADSTRUCTURE;
+
+	adj_val = fdt32_to_cpu(*val);
+	if ((adj_val + delta) < adj_val)
+		return -FDT_ERR_BADPHANDLE;
+
+	adj_val += delta;
+	return fdt_setprop_inplace_u32(fdt, node, name, adj_val);
+}
+
+static int overlay_adjust_node_phandles(void *fdto, int node,
+					uint32_t delta)
+{
+	bool found = false;
+	int child;
+	int ret;
+
+	ret = overlay_phandle_add_offset(fdto, node, "phandle", delta);
+	if (ret && ret != -FDT_ERR_NOTFOUND)
+		return ret;
+
+	if (!ret)
+		found = true;
+
+	ret = overlay_phandle_add_offset(fdto, node, "linux,phandle", delta);
+	if (ret && ret != -FDT_ERR_NOTFOUND)
+		return ret;
+
+	/*
+	 * If neither phandle nor linux,phandle have been found return
+	 * an error.
+	 */
+	if (!found && !ret)
+		return ret;
+
+	fdt_for_each_subnode(fdto, child, node)
+		overlay_adjust_node_phandles(fdto, child, delta);
+
+	return 0;
+}
+
+static int overlay_adjust_local_phandles(void *fdto, uint32_t delta)
+{
+	/*
+	 * Start adjusting the phandles from the overlay root
+	 */
+	return overlay_adjust_node_phandles(fdto, 0, delta);
+}
+
+static int overlay_update_local_node_references(void *fdto,
+						int tree_node,
+						int fixup_node,
+						uint32_t delta)
+{
+	int fixup_prop;
+	int fixup_child;
+	int ret;
+
+	fdt_for_each_property_offset(fixup_prop, fdto, fixup_node) {
+		const uint32_t *val = NULL;
+		uint32_t adj_val, index;
+		const char *name;
+		int fixup_len;
+		int tree_len;
+
+		val = fdt_getprop_by_offset(fdto, fixup_prop,
+					    &name, &fixup_len);
+		if (!val)
+			return fixup_len;
+		index = fdt32_to_cpu(*val);
+
+		val = fdt_getprop(fdto, tree_node, name, &tree_len);
+		if (!val)
+			return tree_len;
+
+		/*
+		 * The index can be unaligned.
+		 *
+		 * Use a memcpy for the architectures that do not
+		 * support unaligned accesses.
+		 */
+		memcpy(&adj_val, (unsigned char *)val + index,
+		       sizeof(uint32_t));
+
+		adj_val = fdt32_to_cpu(adj_val);
+		adj_val += delta;
+		adj_val = cpu_to_fdt32(adj_val);
+
+		ret = fdt_setprop_inplace_namelen_by_index(fdto, tree_node,
+							   name, strlen(name),
+							   index, &adj_val,
+							   sizeof(adj_val));
+		if (ret)
+			return ret;
+	}
+
+	fdt_for_each_subnode(fdto, fixup_child, fixup_node) {
+		const char *fixup_child_name = fdt_get_name(fdto, fixup_child,
+							    NULL);
+		int tree_child;
+
+		tree_child = fdt_subnode_offset(fdto, tree_node,
+						fixup_child_name);
+		if (tree_child < 0)
+			return tree_child;
+
+		ret = overlay_update_local_node_references(fdto,
+							   tree_child,
+							   fixup_child,
+							   delta);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
+static int overlay_update_local_references(void *dto, uint32_t delta)
+{
+	int fixups;
+
+	fixups = fdt_path_offset(dto, "/__local_fixups__");
+	if (fixups < 0) {
+		/* There's no local phandles to adjust, bail out */
+		if (fixups == -FDT_ERR_NOTFOUND)
+			return 0;
+
+		return fixups;
+	}
+
+	/*
+	 * Update our local references from the root of the tree
+	 */
+	return overlay_update_local_node_references(dto, 0, fixups,
+						    delta);
+}
+
+static int overlay_fixup_one_phandle(void *fdt, void *fdto,
+				     int symbols_off,
+				     const char *path, uint32_t path_len,
+				     const char *name, uint32_t name_len,
+				     int index, const char *label)
+{
+	const char *symbol_path;
+	uint32_t phandle;
+	int symbol_off, fixup_off;
+	int prop_len;
+
+	symbol_path = fdt_getprop(fdt, symbols_off, label,
+				  &prop_len);
+	if (!symbol_path)
+		return -FDT_ERR_NOTFOUND;
+
+	symbol_off = fdt_path_offset(fdt, symbol_path);
+	if (symbol_off < 0)
+		return symbol_off;
+
+	phandle = fdt_get_phandle(fdt, symbol_off);
+	if (!phandle)
+		return -FDT_ERR_NOTFOUND;
+
+	fixup_off = fdt_path_offset_namelen(fdto, path, path_len);
+	if (fixup_off < 0)
+		return fixup_off;
+
+	phandle = cpu_to_fdt32(phandle);
+	return fdt_setprop_inplace_namelen_by_index(fdto, fixup_off,
+						    name, name_len, index,
+						    &phandle, sizeof(phandle));
+};
+
+static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
+				 int property)
+{
+	const char *value;
+	const char *label;
+	int len;
+
+	value = fdt_getprop_by_offset(fdto, property,
+				      &label, &len);
+	if (!value)
+		return len;
+
+	do {
+		const char *prop_string = value;
+		const char *path, *name;
+		uint32_t prop_len = strlen(value);
+		uint32_t path_len, name_len;
+		char *sep, *endptr;
+		int index;
+		int ret;
+
+		path = prop_string;
+		sep = memchr(prop_string, ':', prop_len);
+		if (*sep != ':')
+			return -FDT_ERR_BADSTRUCTURE;
+		path_len = sep - path;
+
+		name = sep + 1;
+		sep = memchr(name, ':', prop_len);
+		if (*sep != ':')
+			return -FDT_ERR_BADSTRUCTURE;
+		name_len = sep - name;
+
+		index = strtoul(sep + 1, &endptr, 10);
+		if ((*endptr != '\0') || (endptr <= (sep + 1)))
+			return -FDT_ERR_BADSTRUCTURE;
+
+		len -= prop_len + 1;
+		value += prop_len + 1;
+
+		ret = overlay_fixup_one_phandle(fdt, fdto, symbols_off,
+						path, path_len, name, name_len,
+						index, label);
+		if (ret)
+			return ret;
+	} while (len > 0);
+
+	return 0;
+}
+
+static int overlay_fixup_phandles(void *dt, void *dto)
+{
+	int fixups_off, symbols_off;
+	int property;
+
+	symbols_off = fdt_path_offset(dt, "/__symbols__");
+	fixups_off = fdt_path_offset(dto, "/__fixups__");
+
+	fdt_for_each_property_offset(property, dto, fixups_off)
+		overlay_fixup_phandle(dt, dto, symbols_off, property);
+
+	return 0;
+}
+
+static int apply_overlay_node(void *dt, int target,
+			      void *dto, int fragment)
+{
+	int property;
+	int node;
+
+	fdt_for_each_property_offset(property, dto, fragment) {
+		const char *name;
+		const void *prop;
+		int prop_len;
+		int ret;
+
+		prop = fdt_getprop_by_offset(dto, property, &name,
+					     &prop_len);
+		if (prop_len == -FDT_ERR_NOTFOUND)
+			return -FDT_ERR_INTERNAL;
+		if (prop_len < 0)
+			return prop_len;
+
+		ret = fdt_setprop(dt, target, name, prop, prop_len);
+		if (ret)
+			return ret;
+	}
+
+	fdt_for_each_subnode(dto, node, fragment) {
+		const char *name = fdt_get_name(dto, node, NULL);
+		int nnode;
+		int ret;
+
+		nnode = fdt_add_subnode(dt, target, name);
+		if (nnode == -FDT_ERR_EXISTS)
+			nnode = fdt_subnode_offset(dt, target, name);
+
+		if (nnode < 0)
+			return nnode;
+
+		ret = apply_overlay_node(dt, nnode, dto, node);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
+static int overlay_merge(void *dt, void *dto)
+{
+	int fragment;
+
+	fdt_for_each_subnode(dto, fragment, 0) {
+		int overlay;
+		int target;
+		int ret;
+
+		target = overlay_get_target(dt, dto, fragment);
+		if (target < 0)
+			continue;
+
+		overlay = fdt_subnode_offset(dto, fragment, "__overlay__");
+		if (overlay < 0)
+			return overlay;
+
+		ret = apply_overlay_node(dt, target, dto, overlay);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
+int fdt_overlay_apply(void *fdt, void *fdto)
+{
+	uint32_t delta = fdt_get_max_phandle(fdt) + 1;
+	int ret;
+
+	FDT_CHECK_HEADER(fdt);
+	FDT_CHECK_HEADER(fdto);
+
+	ret = overlay_adjust_local_phandles(fdto, delta);
+	if (ret)
+		goto err;
+
+	ret = overlay_update_local_references(fdto, delta);
+	if (ret)
+		goto err;
+
+	ret = overlay_fixup_phandles(fdt, fdto);
+	if (ret)
+		goto err;
+
+	ret = overlay_merge(fdt, fdto);
+	if (ret)
+		goto err;
+
+	/*
+	 * The overlay has been damaged, erase its magic.
+	 */
+	fdt_set_magic(fdto, ~0);
+
+	return 0;
+
+err:
+	/*
+	 * The overlay might have been damaged, erase its magic.
+	 */
+	fdt_set_magic(fdto, ~0);
+
+	/*
+	 * The base device tree might have been damaged, erase its
+	 * magic.
+	 */
+	fdt_set_magic(fdt, ~0);
+
+	return ret;
+}
-- 
2.9.0

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

* [U-Boot] [PATCH v4 12/13] cmd: fdt: add fdt overlay application subcommand
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: u-boot

The device tree overlays are a good way to deal with user-modifyable
boards or boards with some kind of an expansion mechanism where we can
easily plug new board in (like the BBB or the raspberry pi).

However, so far, the usual mechanism to deal with it was to have in Linux
some driver detecting the expansion boards plugged in and then request
these overlays using the firmware interface.

That works in most cases, but in some cases, you might want to have the
overlays applied before the userspace comes in. Either because the new
board requires some kind of an early initialization, or because your root
filesystem is accessed through that expansion board.

The easiest solution in such a case is to simply have the component before
Linux applying that overlay, removing all these drawbacks.

Reviewed-by: Stefan Agner <stefan@agner.ch>
Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 cmd/fdt.c                | 24 ++++++++++++++++++++++++
 lib/libfdt/fdt_overlay.c | 14 +++++++-------
 2 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 0f5923e75a41..58af7727ba08 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -639,6 +639,27 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 #endif
 
 	}
+#ifdef CONFIG_OF_LIBFDT_OVERLAY
+	/* apply an overlay */
+	else if (strncmp(argv[1], "ap", 2) == 0) {
+		unsigned long addr;
+		struct fdt_header *blob;
+
+		if (argc != 3)
+			return CMD_RET_USAGE;
+
+		if (!working_fdt)
+			return CMD_RET_FAILURE;
+
+		addr = simple_strtoul(argv[2], NULL, 16);
+		blob = map_sysmem(addr, 0);
+		if (!fdt_valid(&blob))
+			return CMD_RET_FAILURE;
+
+		if (fdt_overlay_apply(working_fdt, blob))
+			return CMD_RET_FAILURE;
+	}
+#endif
 	/* resize the fdt */
 	else if (strncmp(argv[1], "re", 2) == 0) {
 		fdt_shrink_to_minimum(working_fdt);
@@ -1025,6 +1046,9 @@ static int fdt_print(const char *pathp, char *prop, int depth)
 #ifdef CONFIG_SYS_LONGHELP
 static char fdt_help_text[] =
 	"addr [-c]  <addr> [<length>]   - Set the [control] fdt location to <addr>\n"
+#ifdef CONFIG_OF_LIBFDT_OVERLAY
+	"fdt apply <addr>                    - Apply overlay to the DT\n"
+#endif
 #ifdef CONFIG_OF_BOARD_SETUP
 	"fdt boardsetup                      - Do board-specific set up\n"
 #endif
diff --git a/lib/libfdt/fdt_overlay.c b/lib/libfdt/fdt_overlay.c
index c45e8b25fb06..1dac8fd48343 100644
--- a/lib/libfdt/fdt_overlay.c
+++ b/lib/libfdt/fdt_overlay.c
@@ -142,10 +142,10 @@ static int overlay_update_local_node_references(void *fdto,
 		adj_val += delta;
 		adj_val = cpu_to_fdt32(adj_val);
 
-		ret = fdt_setprop_inplace_namelen_by_index(fdto, tree_node,
-							   name, strlen(name),
-							   index, &adj_val,
-							   sizeof(adj_val));
+		ret = fdt_setprop_inplace_namelen_partial(fdto, tree_node,
+							  name, strlen(name),
+							  index, &adj_val,
+							  sizeof(adj_val));
 		if (ret)
 			return ret;
 	}
@@ -220,9 +220,9 @@ static int overlay_fixup_one_phandle(void *fdt, void *fdto,
 		return fixup_off;
 
 	phandle = cpu_to_fdt32(phandle);
-	return fdt_setprop_inplace_namelen_by_index(fdto, fixup_off,
-						    name, name_len, index,
-						    &phandle, sizeof(phandle));
+	return fdt_setprop_inplace_namelen_partial(fdto, fixup_off,
+						   name, name_len, index,
+						   &phandle, sizeof(phandle));
 };
 
 static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
-- 
2.9.0

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

* [PATCH v4 12/13] cmd: fdt: add fdt overlay application subcommand
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: Pantelis Antoniou, Simon Glass
  Cc: Boris Brezillon, Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner, David Gibson, Maxime Ripard

The device tree overlays are a good way to deal with user-modifyable
boards or boards with some kind of an expansion mechanism where we can
easily plug new board in (like the BBB or the raspberry pi).

However, so far, the usual mechanism to deal with it was to have in Linux
some driver detecting the expansion boards plugged in and then request
these overlays using the firmware interface.

That works in most cases, but in some cases, you might want to have the
overlays applied before the userspace comes in. Either because the new
board requires some kind of an early initialization, or because your root
filesystem is accessed through that expansion board.

The easiest solution in such a case is to simply have the component before
Linux applying that overlay, removing all these drawbacks.

Reviewed-by: Stefan Agner <stefan-XLVq0VzYD2Y@public.gmane.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 cmd/fdt.c                | 24 ++++++++++++++++++++++++
 lib/libfdt/fdt_overlay.c | 14 +++++++-------
 2 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 0f5923e75a41..58af7727ba08 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -639,6 +639,27 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 #endif
 
 	}
+#ifdef CONFIG_OF_LIBFDT_OVERLAY
+	/* apply an overlay */
+	else if (strncmp(argv[1], "ap", 2) == 0) {
+		unsigned long addr;
+		struct fdt_header *blob;
+
+		if (argc != 3)
+			return CMD_RET_USAGE;
+
+		if (!working_fdt)
+			return CMD_RET_FAILURE;
+
+		addr = simple_strtoul(argv[2], NULL, 16);
+		blob = map_sysmem(addr, 0);
+		if (!fdt_valid(&blob))
+			return CMD_RET_FAILURE;
+
+		if (fdt_overlay_apply(working_fdt, blob))
+			return CMD_RET_FAILURE;
+	}
+#endif
 	/* resize the fdt */
 	else if (strncmp(argv[1], "re", 2) == 0) {
 		fdt_shrink_to_minimum(working_fdt);
@@ -1025,6 +1046,9 @@ static int fdt_print(const char *pathp, char *prop, int depth)
 #ifdef CONFIG_SYS_LONGHELP
 static char fdt_help_text[] =
 	"addr [-c]  <addr> [<length>]   - Set the [control] fdt location to <addr>\n"
+#ifdef CONFIG_OF_LIBFDT_OVERLAY
+	"fdt apply <addr>                    - Apply overlay to the DT\n"
+#endif
 #ifdef CONFIG_OF_BOARD_SETUP
 	"fdt boardsetup                      - Do board-specific set up\n"
 #endif
diff --git a/lib/libfdt/fdt_overlay.c b/lib/libfdt/fdt_overlay.c
index c45e8b25fb06..1dac8fd48343 100644
--- a/lib/libfdt/fdt_overlay.c
+++ b/lib/libfdt/fdt_overlay.c
@@ -142,10 +142,10 @@ static int overlay_update_local_node_references(void *fdto,
 		adj_val += delta;
 		adj_val = cpu_to_fdt32(adj_val);
 
-		ret = fdt_setprop_inplace_namelen_by_index(fdto, tree_node,
-							   name, strlen(name),
-							   index, &adj_val,
-							   sizeof(adj_val));
+		ret = fdt_setprop_inplace_namelen_partial(fdto, tree_node,
+							  name, strlen(name),
+							  index, &adj_val,
+							  sizeof(adj_val));
 		if (ret)
 			return ret;
 	}
@@ -220,9 +220,9 @@ static int overlay_fixup_one_phandle(void *fdt, void *fdto,
 		return fixup_off;
 
 	phandle = cpu_to_fdt32(phandle);
-	return fdt_setprop_inplace_namelen_by_index(fdto, fixup_off,
-						    name, name_len, index,
-						    &phandle, sizeof(phandle));
+	return fdt_setprop_inplace_namelen_partial(fdto, fixup_off,
+						   name, name_len, index,
+						   &phandle, sizeof(phandle));
 };
 
 static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
-- 
2.9.0

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

* [U-Boot] [PATCH v4 13/13] tests: Introduce DT overlay tests
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: u-boot

This adds a bunch of unit tests for the "fdt apply" command.

They've all been run successfully in the sandbox. However, as you still
require an out-of-tree dtc with overlay support, this is disabled by
default.

Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 Makefile                          |   1 +
 include/test/overlay.h            |  16 ++
 include/test/suites.h             |   1 +
 lib/libfdt/fdt_overlay.c          | 311 ++++++++++++++++++++++++++++++++------
 test/Kconfig                      |   1 +
 test/cmd_ut.c                     |   6 +
 test/overlay/Kconfig              |  11 ++
 test/overlay/Makefile             |  15 ++
 test/overlay/cmd_ut_overlay.c     | 268 ++++++++++++++++++++++++++++++++
 test/overlay/test-fdt-base.dts    |  21 +++
 test/overlay/test-fdt-overlay.dts |  96 ++++++++++++
 11 files changed, 698 insertions(+), 49 deletions(-)
 create mode 100644 include/test/overlay.h
 create mode 100644 test/overlay/Kconfig
 create mode 100644 test/overlay/Makefile
 create mode 100644 test/overlay/cmd_ut_overlay.c
 create mode 100644 test/overlay/test-fdt-base.dts
 create mode 100644 test/overlay/test-fdt-overlay.dts

diff --git a/Makefile b/Makefile
index 09a18e1a4dde..a19c56467ae7 100644
--- a/Makefile
+++ b/Makefile
@@ -665,6 +665,7 @@ libs-$(CONFIG_HAS_POST) += post/
 libs-y += test/
 libs-y += test/dm/
 libs-$(CONFIG_UT_ENV) += test/env/
+libs-$(CONFIG_UT_OVERLAY) += test/overlay/
 
 libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
 
diff --git a/include/test/overlay.h b/include/test/overlay.h
new file mode 100644
index 000000000000..392f28ff8405
--- /dev/null
+++ b/include/test/overlay.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2016 NextThing Co
+ * Copyright (c) 2016 Free Electrons
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __TEST_OVERLAY_H__
+#define __TEST_OVERLAY_H__
+
+#include <test/test.h>
+
+/* Declare a new environment test */
+#define OVERLAY_TEST(_name, _flags)	UNIT_TEST(_name, _flags, overlay_test)
+
+#endif /* __TEST_OVERLAY_H__ */
diff --git a/include/test/suites.h b/include/test/suites.h
index f5790333ff8e..0e94feb07a79 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -10,6 +10,7 @@
 
 int do_ut_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 
 #endif /* __TEST_SUITES_H__ */
diff --git a/lib/libfdt/fdt_overlay.c b/lib/libfdt/fdt_overlay.c
index 1dac8fd48343..40b6d274558a 100644
--- a/lib/libfdt/fdt_overlay.c
+++ b/lib/libfdt/fdt_overlay.c
@@ -5,6 +5,20 @@
 
 #include "libfdt_internal.h"
 
+/**
+ * overlay_get_target_phandle - retrieves the target phandle of a fragment
+ * @fdto: pointer to the device tree overlay blob
+ * @fragment: node offset of the fragment in the overlay
+ *
+ * overlay_get_target_phandle() retrieves the target phandle of an
+ * overlay fragment when that fragment uses a phandle (target
+ * property) instead of a path (target-path property).
+ *
+ * returns:
+ *      the phandle pointed by the target property
+ *      0, if the phandle was not found
+ *	-1, if the phandle was malformed
+ */
 static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
 {
 	const uint32_t *val;
@@ -14,12 +28,26 @@ static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
 	if (!val)
 		return 0;
 
-	if ((*val == 0xffffffff) || (len != sizeof(*val)))
-		return 0xffffffff;
+	if ((*val == (uint32_t)-1) || (len != sizeof(*val)))
+		return (uint32_t)-1;
 
 	return fdt32_to_cpu(*val);
 }
 
+/**
+ * overlay_get_target - retrieves the target phandle of a fragment
+ * @fdt: Base device tree blob
+ * @fdto: Device tree overlay blob
+ * @fragment: node offset of the fragment in the overlay
+ *
+ * overlay_get_target() retrieves the target phandle in the base
+ * device tree of a fragment, no matter how the actual targetting is
+ * done (through a phandle or a path)
+ *
+ * returns:
+ *      the targetted node offset in the base device tree
+ *      Negative error code on error
+ */
 static int overlay_get_target(const void *fdt, const void *fdto,
 			      int fragment)
 {
@@ -28,7 +56,7 @@ static int overlay_get_target(const void *fdt, const void *fdto,
 
 	/* Try first to do a phandle based lookup */
 	phandle = overlay_get_target_phandle(fdto, fragment);
-	if (phandle == -1)
+	if (phandle == (uint32_t)-1)
 		return -FDT_ERR_BADPHANDLE;
 
 	if (phandle)
@@ -42,6 +70,20 @@ static int overlay_get_target(const void *fdt, const void *fdto,
 	return fdt_path_offset(fdt, path);
 }
 
+/**
+ * overlay_phandle_add_offset - Increases a phandle by an offset
+ * @fdt: Base device tree blob
+ * @node: Device tree overlay blob
+ * @name: Name of the property to modify (phandle or linux,phandle)
+ * @delta: offset to apply
+ *
+ * overlay_phandle_add_offset() increments a node phandle by a given
+ * offset.
+ *
+ * returns:
+ *      0 on success.
+ *      Negative error code on error
+ */
 static int overlay_phandle_add_offset(void *fdt, int node,
 				      const char *name, uint32_t delta)
 {
@@ -64,6 +106,21 @@ static int overlay_phandle_add_offset(void *fdt, int node,
 	return fdt_setprop_inplace_u32(fdt, node, name, adj_val);
 }
 
+/**
+ * overlay_adjust_node_phandles - Offsets the phandles of a node
+ * @fdto: Device tree overlay blob
+ * @node: Offset of the node we want to adjust
+ * @delta: Offset to shift the phandles of
+ *
+ * overlay_adjust_node_phandles() adds a constant to all the phandles
+ * of a given node. This is mainly use as part of the overlay
+ * application process, when we want to update all the overlay
+ * phandles to not conflict with the overlays of the base device tree.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
 static int overlay_adjust_node_phandles(void *fdto, int node,
 					uint32_t delta)
 {
@@ -95,6 +152,20 @@ static int overlay_adjust_node_phandles(void *fdto, int node,
 	return 0;
 }
 
+/**
+ * overlay_adjust_local_phandles - Adjust the phandles of a whole overlay
+ * @fdto: Device tree overlay blob
+ * @delta: Offset to shift the phandles of
+ *
+ * overlay_adjust_local_phandles() adds a constant to all the
+ * phandles of an overlay. This is mainly use as part of the overlay
+ * application process, when we want to update all the overlay
+ * phandles to not conflict with the overlays of the base device tree.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
 static int overlay_adjust_local_phandles(void *fdto, uint32_t delta)
 {
 	/*
@@ -103,6 +174,25 @@ static int overlay_adjust_local_phandles(void *fdto, uint32_t delta)
 	return overlay_adjust_node_phandles(fdto, 0, delta);
 }
 
+/**
+ * overlay_update_local_node_references - Adjust the overlay references
+ * @fdto: Device tree overlay blob
+ * @tree_node: Node offset of the node to operate on
+ * @fixup_node: Node offset of the matching local fixups node
+ * @delta: Offset to shift the phandles of
+ *
+ * overlay_update_local_nodes_references() update the phandles
+ * pointing to a node within the device tree overlay by adding a
+ * constant delta.
+ *
+ * This is mainly used as part of a device tree application process,
+ * where you want the device tree overlays phandles to not conflict
+ * with the ones from the base device tree before merging them.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
 static int overlay_update_local_node_references(void *fdto,
 						int tree_node,
 						int fixup_node,
@@ -113,41 +203,49 @@ static int overlay_update_local_node_references(void *fdto,
 	int ret;
 
 	fdt_for_each_property_offset(fixup_prop, fdto, fixup_node) {
-		const uint32_t *val = NULL;
-		uint32_t adj_val, index;
+		const unsigned char *fixup_val, *tree_val;
 		const char *name;
 		int fixup_len;
 		int tree_len;
+		int i;
 
-		val = fdt_getprop_by_offset(fdto, fixup_prop,
-					    &name, &fixup_len);
-		if (!val)
+		fixup_val = fdt_getprop_by_offset(fdto, fixup_prop,
+						  &name, &fixup_len);
+		if (!fixup_val)
 			return fixup_len;
-		index = fdt32_to_cpu(*val);
 
-		val = fdt_getprop(fdto, tree_node, name, &tree_len);
-		if (!val)
+		tree_val = fdt_getprop(fdto, tree_node, name, &tree_len);
+		if (!tree_val)
 			return tree_len;
 
-		/*
-		 * The index can be unaligned.
-		 *
-		 * Use a memcpy for the architectures that do not
-		 * support unaligned accesses.
-		 */
-		memcpy(&adj_val, (unsigned char *)val + index,
-		       sizeof(uint32_t));
-
-		adj_val = fdt32_to_cpu(adj_val);
-		adj_val += delta;
-		adj_val = cpu_to_fdt32(adj_val);
-
-		ret = fdt_setprop_inplace_namelen_partial(fdto, tree_node,
-							  name, strlen(name),
-							  index, &adj_val,
-							  sizeof(adj_val));
-		if (ret)
-			return ret;
+		for (i = 0; i < fixup_len; i += sizeof(uint32_t)) {
+			uint32_t adj_val, index;
+
+			index = *(uint32_t *)(fixup_val + i);
+			index = fdt32_to_cpu(index);
+
+			/*
+			 * phandles to fixup can be unaligned.
+			 *
+			 * Use a memcpy for the architectures that do
+			 * not support unaligned accesses.
+			 */
+			memcpy(&adj_val, tree_val + index, sizeof(uint32_t));
+
+			adj_val = fdt32_to_cpu(adj_val);
+			adj_val += delta;
+			adj_val = cpu_to_fdt32(adj_val);
+
+			ret = fdt_setprop_inplace_namelen_partial(fdto,
+								  tree_node,
+								  name,
+								  strlen(name),
+								  index,
+								  &adj_val,
+								  sizeof(adj_val));
+			if (ret)
+				return ret;
+		}
 	}
 
 	fdt_for_each_subnode(fdto, fixup_child, fixup_node) {
@@ -171,11 +269,28 @@ static int overlay_update_local_node_references(void *fdto,
 	return 0;
 }
 
-static int overlay_update_local_references(void *dto, uint32_t delta)
+/**
+ * overlay_update_local_references - Adjust the overlay references
+ * @fdto: Device tree overlay blob
+ * @delta: Offset to shift the phandles of
+ *
+ * overlay_update_local_references() update all the phandles pointing
+ * to a node within the device tree overlay by adding a constant
+ * delta to not conflict with the base overlay.
+ *
+ * This is mainly used as part of a device tree application process,
+ * where you want the device tree overlays phandles to not conflict
+ * with the ones from the base device tree before merging them.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
+static int overlay_update_local_references(void *fdto, uint32_t delta)
 {
 	int fixups;
 
-	fixups = fdt_path_offset(dto, "/__local_fixups__");
+	fixups = fdt_path_offset(fdto, "/__local_fixups__");
 	if (fixups < 0) {
 		/* There's no local phandles to adjust, bail out */
 		if (fixups == -FDT_ERR_NOTFOUND)
@@ -187,10 +302,33 @@ static int overlay_update_local_references(void *dto, uint32_t delta)
 	/*
 	 * Update our local references from the root of the tree
 	 */
-	return overlay_update_local_node_references(dto, 0, fixups,
+	return overlay_update_local_node_references(fdto, 0, fixups,
 						    delta);
 }
 
+/**
+ * overlay_fixup_one_phandle - Set an overlay phandle to the base one
+ * @fdt: Base Device Tree blob
+ * @fdto: Device tree overlay blob
+ * @symbols_off: Node offset of the symbols node in the base device tree
+ * @path: Path to a node holding a phandle in the overlay
+ * @path_len: number of path characters to consider
+ * @name: Name of the property holding the phandle reference in the overlay
+ * @name_len: number of name characters to consider
+ * @index: Index in the overlay property where the phandle is stored
+ * @label: Label of the node referenced by the phandle
+ *
+ * overlay_fixup_one_phandle() resolves an overlay phandle pointing to
+ * a node in the base device tree.
+ *
+ * This is part of the device tree overlay application process, when
+ * you want all the phandles in the overlay to point to the actual
+ * base dt nodes.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
 static int overlay_fixup_one_phandle(void *fdt, void *fdto,
 				     int symbols_off,
 				     const char *path, uint32_t path_len,
@@ -225,6 +363,25 @@ static int overlay_fixup_one_phandle(void *fdt, void *fdto,
 						   &phandle, sizeof(phandle));
 };
 
+/**
+ * overlay_fixup_phandle - Set an overlay phandle to the base one
+ * @fdt: Base Device Tree blob
+ * @fdto: Device tree overlay blob
+ * @symbols_off: Node offset of the symbols node in the base device tree
+ * @property: Property offset in the overlay holding the list of fixups
+ *
+ * overlay_fixup_phandle() resolves all the overlay phandles pointed
+ * to in a __local_fixup__ property, and updates them to match the
+ * phandles in use in the base device tree.
+ *
+ * This is part of the device tree overlay application process, when
+ * you want all the phandles in the overlay to point to the actual
+ * base dt nodes.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
 static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
 				 int property)
 {
@@ -275,57 +432,98 @@ static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
 	return 0;
 }
 
-static int overlay_fixup_phandles(void *dt, void *dto)
+/**
+ * overlay_fixup_phandles - Resolve the overlay phandles to the base
+ *                          device tree
+ * @fdt: Base Device Tree blob
+ * @fdto: Device tree overlay blob
+ *
+ * overlay_fixup_phandles() resolves all the overlay phandles pointing
+ * to nodes in the base device tree.
+ *
+ * This is one of the steps of the device tree overlay application
+ * process, when you want all the phandles in the overlay to point to
+ * the actual base dt nodes.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
+static int overlay_fixup_phandles(void *fdt, void *fdto)
 {
 	int fixups_off, symbols_off;
 	int property;
 
-	symbols_off = fdt_path_offset(dt, "/__symbols__");
-	fixups_off = fdt_path_offset(dto, "/__fixups__");
+	symbols_off = fdt_path_offset(fdt, "/__symbols__");
+	fixups_off = fdt_path_offset(fdto, "/__fixups__");
+
+	fdt_for_each_property_offset(property, fdto, fixups_off) {
+		int ret;
 
-	fdt_for_each_property_offset(property, dto, fixups_off)
-		overlay_fixup_phandle(dt, dto, symbols_off, property);
+		ret = overlay_fixup_phandle(fdt, fdto, symbols_off, property);
+		if (ret)
+			return ret;
+	}
 
 	return 0;
 }
 
-static int apply_overlay_node(void *dt, int target,
-			      void *dto, int fragment)
+/**
+ * overlay_apply_node - Merge an overlay fragment into the base device tree
+ * @fdt: Base Device Tree blob
+ * @target: Node offset in the base device tree to apply the fragment to
+ * @fdto: Device tree overlay blob
+ * @fragment: Node offset in the overlay holding the changes to merge
+ *
+ * overlay_apply_node() merges an overlay fragment into a target base
+ * device tree node pointed.
+ *
+ * This is part of the final step in the device tree overlay
+ * application process, when all the phandles have been adjusted and
+ * resolved and you just have to merge overlay into the base device
+ * tree.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
+static int overlay_apply_node(void *fdt, int target,
+			      void *fdto, int fragment)
 {
 	int property;
 	int node;
 
-	fdt_for_each_property_offset(property, dto, fragment) {
+	fdt_for_each_property_offset(property, fdto, fragment) {
 		const char *name;
 		const void *prop;
 		int prop_len;
 		int ret;
 
-		prop = fdt_getprop_by_offset(dto, property, &name,
+		prop = fdt_getprop_by_offset(fdto, property, &name,
 					     &prop_len);
 		if (prop_len == -FDT_ERR_NOTFOUND)
 			return -FDT_ERR_INTERNAL;
 		if (prop_len < 0)
 			return prop_len;
 
-		ret = fdt_setprop(dt, target, name, prop, prop_len);
+		ret = fdt_setprop(fdt, target, name, prop, prop_len);
 		if (ret)
 			return ret;
 	}
 
-	fdt_for_each_subnode(dto, node, fragment) {
-		const char *name = fdt_get_name(dto, node, NULL);
+	fdt_for_each_subnode(fdto, node, fragment) {
+		const char *name = fdt_get_name(fdto, node, NULL);
 		int nnode;
 		int ret;
 
-		nnode = fdt_add_subnode(dt, target, name);
+		nnode = fdt_add_subnode(fdt, target, name);
 		if (nnode == -FDT_ERR_EXISTS)
-			nnode = fdt_subnode_offset(dt, target, name);
+			nnode = fdt_subnode_offset(fdt, target, name);
 
 		if (nnode < 0)
 			return nnode;
 
-		ret = apply_overlay_node(dt, nnode, dto, node);
+		ret = overlay_apply_node(fdt, nnode, fdto, node);
 		if (ret)
 			return ret;
 	}
@@ -333,6 +531,21 @@ static int apply_overlay_node(void *dt, int target,
 	return 0;
 }
 
+/**
+ * overlay_merge - Merge an overlay into its base device tree
+ * @fdt: Base Device Tree blob
+ * @fdto: Device tree overlay blob
+ *
+ * overlay_merge() merges an overlay into its base device tree.
+ *
+ * This is the final step in the device tree overlay application
+ * process, when all the phandles have been adjusted and resolved and
+ * you just have to merge overlay into the base device tree.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
 static int overlay_merge(void *dt, void *dto)
 {
 	int fragment;
@@ -350,7 +563,7 @@ static int overlay_merge(void *dt, void *dto)
 		if (overlay < 0)
 			return overlay;
 
-		ret = apply_overlay_node(dt, target, dto, overlay);
+		ret = overlay_apply_node(dt, target, dto, overlay);
 		if (ret)
 			return ret;
 	}
diff --git a/test/Kconfig b/test/Kconfig
index d71c332eee27..3643761bc6ef 100644
--- a/test/Kconfig
+++ b/test/Kconfig
@@ -17,3 +17,4 @@ config UT_TIME
 
 source "test/dm/Kconfig"
 source "test/env/Kconfig"
+source "test/overlay/Kconfig"
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index f6e1f413db7f..14333423a178 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -19,6 +19,9 @@ static cmd_tbl_t cmd_ut_sub[] = {
 #if defined(CONFIG_UT_ENV)
 	U_BOOT_CMD_MKENT(env, CONFIG_SYS_MAXARGS, 1, do_ut_env, "", ""),
 #endif
+#ifdef CONFIG_UT_OVERLAY
+	U_BOOT_CMD_MKENT(overlay, CONFIG_SYS_MAXARGS, 1, do_ut_overlay, "", ""),
+#endif
 #ifdef CONFIG_UT_TIME
 	U_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, "", ""),
 #endif
@@ -68,6 +71,9 @@ static char ut_help_text[] =
 #ifdef CONFIG_UT_ENV
 	"ut env [test-name]\n"
 #endif
+#ifdef CONFIG_UT_OVERLAY
+	"ut overlay [test-name]\n"
+#endif
 #ifdef CONFIG_UT_TIME
 	"ut time - Very basic test of time functions\n"
 #endif
diff --git a/test/overlay/Kconfig b/test/overlay/Kconfig
new file mode 100644
index 000000000000..13c85428cbaa
--- /dev/null
+++ b/test/overlay/Kconfig
@@ -0,0 +1,11 @@
+config UT_OVERLAY
+	bool "Enable Device Tree Overlays Unit Tests"
+	depends on OF_LIBFDT_OVERLAY
+	depends on UNIT_TEST
+	help
+	  This enables the 'ut overlay' command which runs a series of unit
+	  tests on the fdt overlay code.
+	  If all is well then all tests pass although there will be a few
+	  messages printed along the way.
+	  Be warned that it requires an out-of-tree dtc compiler with patches
+	  to support the DT overlays, otherwise it will fail.
diff --git a/test/overlay/Makefile b/test/overlay/Makefile
new file mode 100644
index 000000000000..907f08544619
--- /dev/null
+++ b/test/overlay/Makefile
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2016 NextThing Co
+# Copyright (c) 2016 Free Electrons
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+# Test files
+obj-y += cmd_ut_overlay.o
+
+DTC_FLAGS += -@
+
+# DT overlays
+obj-y += test-fdt-base.dtb.o
+obj-y += test-fdt-overlay.dtb.o
diff --git a/test/overlay/cmd_ut_overlay.c b/test/overlay/cmd_ut_overlay.c
new file mode 100644
index 000000000000..87dc9328c674
--- /dev/null
+++ b/test/overlay/cmd_ut_overlay.c
@@ -0,0 +1,268 @@
+/*
+ * Copyright (c) 2016 NextThing Co
+ * Copyright (c) 2016 Free Electrons
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <command.h>
+#include <errno.h>
+#include <malloc.h>
+
+#include <linux/sizes.h>
+
+#include <test/ut.h>
+#include <test/overlay.h>
+
+/* 4k ought to be enough for anybody */
+#define FDT_COPY_SIZE	(4 * SZ_1K)
+
+extern u32 __dtb_test_fdt_base_begin;
+extern u32 __dtb_test_fdt_overlay_begin;
+
+static int fdt_getprop_u32_by_index(void *fdt, const char *path,
+				    const char *name, int index,
+				    u32 *out)
+{
+	const fdt32_t *val;
+	int node_off;
+	int len;
+
+	node_off = fdt_path_offset(fdt, path);
+	if (node_off < 0)
+		return node_off;
+
+	val = fdt_getprop(fdt, node_off, name, &len);
+	if (!val || (len < (sizeof(uint32_t) * (index + 1))))
+		return -FDT_ERR_NOTFOUND;
+
+	*out = fdt32_to_cpu(*(val + index));
+
+	return 0;
+}
+
+static int fdt_getprop_u32(void *fdt, const char *path, const char *name,
+			   u32 *out)
+{
+	return fdt_getprop_u32_by_index(fdt, path, name, 0, out);
+}
+
+static int fdt_getprop_str(void *fdt, const char *path, const char *name,
+			   const char **out)
+{
+	int node_off;
+
+	node_off = fdt_path_offset(fdt, path);
+	if (node_off < 0)
+		return node_off;
+
+	return fdt_get_string(fdt, node_off, name, out);
+}
+
+static int fdt_overlay_change_int_property(struct unit_test_state *uts)
+{
+	void *fdt = uts->priv;
+	u32 val = 0;
+
+	ut_assertok(fdt_getprop_u32(fdt, "/test-node", "test-int-property",
+				    &val));
+	ut_asserteq(43, val);
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_change_int_property, 0);
+
+static int fdt_overlay_change_str_property(struct unit_test_state *uts)
+{
+	void *fdt = uts->priv;
+	const char *val = NULL;
+
+	ut_assertok(fdt_getprop_str(fdt, "/test-node", "test-str-property",
+				    &val));
+	ut_asserteq_str("foobar", val);
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_change_str_property, 0);
+
+static int fdt_overlay_add_str_property(struct unit_test_state *uts)
+{
+	void *fdt = uts->priv;
+	const char *val = NULL;
+
+	ut_assertok(fdt_getprop_str(fdt, "/test-node", "test-str-property-2",
+				    &val));
+	ut_asserteq_str("foobar2", val);
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_add_str_property, 0);
+
+static int fdt_overlay_add_node_by_phandle(struct unit_test_state *uts)
+{
+	void *fdt = uts->priv;
+	int off;
+
+	off = fdt_path_offset(fdt, "/test-node/new-node");
+	ut_assert(off >= 0);
+
+	ut_assertnonnull(fdt_getprop(fdt, off, "new-property", NULL));
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_add_node_by_phandle, 0);
+
+static int fdt_overlay_add_node_by_path(struct unit_test_state *uts)
+{
+	void *fdt = uts->priv;
+	int off;
+
+	off = fdt_path_offset(fdt, "/new-node");
+	ut_assert(off >= 0);
+
+	ut_assertnonnull(fdt_getprop(fdt, off, "new-property", NULL));
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_add_node_by_path, 0);
+
+static int fdt_overlay_add_subnode_property(struct unit_test_state *uts)
+{
+	void *fdt = uts->priv;
+	int off;
+
+	off = fdt_path_offset(fdt, "/test-node/sub-test-node");
+	ut_assert(off >= 0);
+
+	ut_assertnonnull(fdt_getprop(fdt, off, "sub-test-property", NULL));
+	ut_assertnonnull(fdt_getprop(fdt, off, "new-sub-test-property", NULL));
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_add_subnode_property, 0);
+
+static int fdt_overlay_local_phandle(struct unit_test_state *uts)
+{
+	uint32_t local_phandle;
+	void *fdt = uts->priv;
+	u32 val = 0;
+	int off;
+
+	off = fdt_path_offset(fdt, "/new-local-node");
+	ut_assert(off >= 0);
+
+	local_phandle = fdt_get_phandle(fdt, off);
+	ut_assert(local_phandle);
+
+	ut_assertok(fdt_getprop_u32_by_index(fdt, "/", "test-several-phandle",
+					     0, &val));
+	ut_asserteq(local_phandle, val);
+
+	ut_assertok(fdt_getprop_u32_by_index(fdt, "/", "test-several-phandle",
+					     1, &val));
+	ut_asserteq(local_phandle, val);
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_local_phandle, 0);
+
+static int fdt_overlay_local_phandles(struct unit_test_state *uts)
+{
+	uint32_t local_phandle, test_phandle;
+	void *fdt = uts->priv;
+	u32 val = 0;
+	int off;
+
+	off = fdt_path_offset(fdt, "/new-local-node");
+	ut_assert(off >= 0);
+
+	local_phandle = fdt_get_phandle(fdt, off);
+	ut_assert(local_phandle);
+
+	off = fdt_path_offset(fdt, "/test-node");
+	ut_assert(off >= 0);
+
+	test_phandle = fdt_get_phandle(fdt, off);
+	ut_assert(test_phandle);
+
+	ut_assertok(fdt_getprop_u32_by_index(fdt, "/", "test-phandle", 0,
+					     &val));
+	ut_asserteq(test_phandle, val);
+
+	ut_assertok(fdt_getprop_u32_by_index(fdt, "/", "test-phandle", 1,
+					     &val));
+	ut_asserteq(local_phandle, val);
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_local_phandles, 0);
+
+int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	struct unit_test *tests = ll_entry_start(struct unit_test,
+						 overlay_test);
+	const int n_ents = ll_entry_count(struct unit_test, overlay_test);
+	struct unit_test_state *uts;
+	struct unit_test *test;
+	void *fdt_base = &__dtb_test_fdt_base_begin;
+	void *fdt_overlay = &__dtb_test_fdt_overlay_begin;
+	void *fdt_base_copy, *fdt_overlay_copy;
+
+	uts = calloc(1, sizeof(*uts));
+	if (!uts)
+		return -ENOMEM;
+
+	ut_assertok(fdt_check_header(fdt_base));
+	ut_assertok(fdt_check_header(fdt_overlay));
+
+	fdt_base_copy = malloc(FDT_COPY_SIZE);
+	if (!fdt_base_copy)
+		return -ENOMEM;
+	uts->priv = fdt_base_copy;
+
+	fdt_overlay_copy = malloc(FDT_COPY_SIZE);
+	if (!fdt_overlay_copy)
+		return -ENOMEM;
+
+	/*
+	 * Resize the FDT to 4k so that we have room to operate on
+	 *
+	 * (and relocate it since the memory might be mapped
+	 * read-only)
+	 */
+	ut_assertok(fdt_open_into(fdt_base, fdt_base_copy, FDT_COPY_SIZE));
+
+	/*
+	 * Resize the overlay to 4k so that we have room to operate on
+	 *
+	 * (and relocate it since the memory might be mapped
+	 * read-only)
+	 */
+	ut_assertok(fdt_open_into(fdt_overlay, fdt_overlay_copy,
+				  FDT_COPY_SIZE));
+
+	/* Apply the overlay */
+	ut_assertok(fdt_overlay_apply(fdt_base_copy, fdt_overlay_copy));
+
+	if (argc == 1)
+		printf("Running %d environment tests\n", n_ents);
+
+	for (test = tests; test < tests + n_ents; test++) {
+		if (argc > 1 && strcmp(argv[1], test->name))
+			continue;
+		printf("Test: %s\n", test->name);
+
+		uts->start = mallinfo();
+
+		test->func(uts);
+	}
+
+	printf("Failures: %d\n", uts->fail_count);
+
+	free(fdt_overlay_copy);
+	free(fdt_base_copy);
+	free(uts);
+
+	return uts->fail_count ? CMD_RET_FAILURE : 0;
+}
diff --git a/test/overlay/test-fdt-base.dts b/test/overlay/test-fdt-base.dts
new file mode 100644
index 000000000000..2603adb6821e
--- /dev/null
+++ b/test/overlay/test-fdt-base.dts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2016 NextThing Co
+ * Copyright (c) 2016 Free Electrons
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+/dts-v1/;
+
+/ {
+	test: test-node {
+		test-int-property = <42>;
+		test-str-property = "foo";
+
+		subtest: sub-test-node {
+			sub-test-property;
+		};
+	};
+};
+
+
diff --git a/test/overlay/test-fdt-overlay.dts b/test/overlay/test-fdt-overlay.dts
new file mode 100644
index 000000000000..d30ecdf3661c
--- /dev/null
+++ b/test/overlay/test-fdt-overlay.dts
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2016 NextThing Co
+ * Copyright (c) 2016 Free Electrons
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+/dts-v1/;
+/plugin/;
+
+/ {
+	/* Test that we can change an int by another */
+	fragment at 0 {
+		target = <&test>;
+
+		__overlay__ {
+			test-int-property = <43>;
+		};
+	};
+
+	/* Test that we can replace a string by a longer one */
+	fragment at 1 {
+		target = <&test>;
+
+		__overlay__ {
+			test-str-property = "foobar";
+		};
+	};
+
+	/* Test that we add a new property */
+	fragment at 2 {
+		target = <&test>;
+
+		__overlay__ {
+			test-str-property-2 = "foobar2";
+		};
+	};
+
+	/* Test that we add a new node (by phandle) */
+	fragment at 3 {
+		target = <&test>;
+
+		__overlay__ {
+			new-node {
+				new-property;
+			};
+		};
+	};
+
+	/* Test that we add a new node (by path) */
+	fragment at 4 {
+		target-path = "/";
+
+		__overlay__ {
+			new-node {
+				new-property;
+			};
+		};
+	};
+
+	fragment at 5 {
+		target-path = "/";
+
+		__overlay__ {
+			local: new-local-node {
+				new-property;
+			};
+		};
+	};
+
+	fragment at 6 {
+		target-path = "/";
+
+		__overlay__ {
+			test-phandle = <&test>, <&local>;
+		};
+	};
+
+	fragment at 7 {
+		target-path = "/";
+
+		__overlay__ {
+			test-several-phandle = <&local>, <&local>;
+		};
+	};
+
+	fragment at 8 {
+		target = <&test>;
+
+		__overlay__ {
+			sub-test-node {
+				new-sub-test-property;
+			};
+		};
+	};
+};
-- 
2.9.0

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

* [PATCH v4 13/13] tests: Introduce DT overlay tests
@ 2016-07-05  8:26   ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-05  8:26 UTC (permalink / raw)
  To: Pantelis Antoniou, Simon Glass
  Cc: Boris Brezillon, Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner, David Gibson, Maxime Ripard

This adds a bunch of unit tests for the "fdt apply" command.

They've all been run successfully in the sandbox. However, as you still
require an out-of-tree dtc with overlay support, this is disabled by
default.

Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 Makefile                          |   1 +
 include/test/overlay.h            |  16 ++
 include/test/suites.h             |   1 +
 lib/libfdt/fdt_overlay.c          | 311 ++++++++++++++++++++++++++++++++------
 test/Kconfig                      |   1 +
 test/cmd_ut.c                     |   6 +
 test/overlay/Kconfig              |  11 ++
 test/overlay/Makefile             |  15 ++
 test/overlay/cmd_ut_overlay.c     | 268 ++++++++++++++++++++++++++++++++
 test/overlay/test-fdt-base.dts    |  21 +++
 test/overlay/test-fdt-overlay.dts |  96 ++++++++++++
 11 files changed, 698 insertions(+), 49 deletions(-)
 create mode 100644 include/test/overlay.h
 create mode 100644 test/overlay/Kconfig
 create mode 100644 test/overlay/Makefile
 create mode 100644 test/overlay/cmd_ut_overlay.c
 create mode 100644 test/overlay/test-fdt-base.dts
 create mode 100644 test/overlay/test-fdt-overlay.dts

diff --git a/Makefile b/Makefile
index 09a18e1a4dde..a19c56467ae7 100644
--- a/Makefile
+++ b/Makefile
@@ -665,6 +665,7 @@ libs-$(CONFIG_HAS_POST) += post/
 libs-y += test/
 libs-y += test/dm/
 libs-$(CONFIG_UT_ENV) += test/env/
+libs-$(CONFIG_UT_OVERLAY) += test/overlay/
 
 libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
 
diff --git a/include/test/overlay.h b/include/test/overlay.h
new file mode 100644
index 000000000000..392f28ff8405
--- /dev/null
+++ b/include/test/overlay.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2016 NextThing Co
+ * Copyright (c) 2016 Free Electrons
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __TEST_OVERLAY_H__
+#define __TEST_OVERLAY_H__
+
+#include <test/test.h>
+
+/* Declare a new environment test */
+#define OVERLAY_TEST(_name, _flags)	UNIT_TEST(_name, _flags, overlay_test)
+
+#endif /* __TEST_OVERLAY_H__ */
diff --git a/include/test/suites.h b/include/test/suites.h
index f5790333ff8e..0e94feb07a79 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -10,6 +10,7 @@
 
 int do_ut_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 
 #endif /* __TEST_SUITES_H__ */
diff --git a/lib/libfdt/fdt_overlay.c b/lib/libfdt/fdt_overlay.c
index 1dac8fd48343..40b6d274558a 100644
--- a/lib/libfdt/fdt_overlay.c
+++ b/lib/libfdt/fdt_overlay.c
@@ -5,6 +5,20 @@
 
 #include "libfdt_internal.h"
 
+/**
+ * overlay_get_target_phandle - retrieves the target phandle of a fragment
+ * @fdto: pointer to the device tree overlay blob
+ * @fragment: node offset of the fragment in the overlay
+ *
+ * overlay_get_target_phandle() retrieves the target phandle of an
+ * overlay fragment when that fragment uses a phandle (target
+ * property) instead of a path (target-path property).
+ *
+ * returns:
+ *      the phandle pointed by the target property
+ *      0, if the phandle was not found
+ *	-1, if the phandle was malformed
+ */
 static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
 {
 	const uint32_t *val;
@@ -14,12 +28,26 @@ static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
 	if (!val)
 		return 0;
 
-	if ((*val == 0xffffffff) || (len != sizeof(*val)))
-		return 0xffffffff;
+	if ((*val == (uint32_t)-1) || (len != sizeof(*val)))
+		return (uint32_t)-1;
 
 	return fdt32_to_cpu(*val);
 }
 
+/**
+ * overlay_get_target - retrieves the target phandle of a fragment
+ * @fdt: Base device tree blob
+ * @fdto: Device tree overlay blob
+ * @fragment: node offset of the fragment in the overlay
+ *
+ * overlay_get_target() retrieves the target phandle in the base
+ * device tree of a fragment, no matter how the actual targetting is
+ * done (through a phandle or a path)
+ *
+ * returns:
+ *      the targetted node offset in the base device tree
+ *      Negative error code on error
+ */
 static int overlay_get_target(const void *fdt, const void *fdto,
 			      int fragment)
 {
@@ -28,7 +56,7 @@ static int overlay_get_target(const void *fdt, const void *fdto,
 
 	/* Try first to do a phandle based lookup */
 	phandle = overlay_get_target_phandle(fdto, fragment);
-	if (phandle == -1)
+	if (phandle == (uint32_t)-1)
 		return -FDT_ERR_BADPHANDLE;
 
 	if (phandle)
@@ -42,6 +70,20 @@ static int overlay_get_target(const void *fdt, const void *fdto,
 	return fdt_path_offset(fdt, path);
 }
 
+/**
+ * overlay_phandle_add_offset - Increases a phandle by an offset
+ * @fdt: Base device tree blob
+ * @node: Device tree overlay blob
+ * @name: Name of the property to modify (phandle or linux,phandle)
+ * @delta: offset to apply
+ *
+ * overlay_phandle_add_offset() increments a node phandle by a given
+ * offset.
+ *
+ * returns:
+ *      0 on success.
+ *      Negative error code on error
+ */
 static int overlay_phandle_add_offset(void *fdt, int node,
 				      const char *name, uint32_t delta)
 {
@@ -64,6 +106,21 @@ static int overlay_phandle_add_offset(void *fdt, int node,
 	return fdt_setprop_inplace_u32(fdt, node, name, adj_val);
 }
 
+/**
+ * overlay_adjust_node_phandles - Offsets the phandles of a node
+ * @fdto: Device tree overlay blob
+ * @node: Offset of the node we want to adjust
+ * @delta: Offset to shift the phandles of
+ *
+ * overlay_adjust_node_phandles() adds a constant to all the phandles
+ * of a given node. This is mainly use as part of the overlay
+ * application process, when we want to update all the overlay
+ * phandles to not conflict with the overlays of the base device tree.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
 static int overlay_adjust_node_phandles(void *fdto, int node,
 					uint32_t delta)
 {
@@ -95,6 +152,20 @@ static int overlay_adjust_node_phandles(void *fdto, int node,
 	return 0;
 }
 
+/**
+ * overlay_adjust_local_phandles - Adjust the phandles of a whole overlay
+ * @fdto: Device tree overlay blob
+ * @delta: Offset to shift the phandles of
+ *
+ * overlay_adjust_local_phandles() adds a constant to all the
+ * phandles of an overlay. This is mainly use as part of the overlay
+ * application process, when we want to update all the overlay
+ * phandles to not conflict with the overlays of the base device tree.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
 static int overlay_adjust_local_phandles(void *fdto, uint32_t delta)
 {
 	/*
@@ -103,6 +174,25 @@ static int overlay_adjust_local_phandles(void *fdto, uint32_t delta)
 	return overlay_adjust_node_phandles(fdto, 0, delta);
 }
 
+/**
+ * overlay_update_local_node_references - Adjust the overlay references
+ * @fdto: Device tree overlay blob
+ * @tree_node: Node offset of the node to operate on
+ * @fixup_node: Node offset of the matching local fixups node
+ * @delta: Offset to shift the phandles of
+ *
+ * overlay_update_local_nodes_references() update the phandles
+ * pointing to a node within the device tree overlay by adding a
+ * constant delta.
+ *
+ * This is mainly used as part of a device tree application process,
+ * where you want the device tree overlays phandles to not conflict
+ * with the ones from the base device tree before merging them.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
 static int overlay_update_local_node_references(void *fdto,
 						int tree_node,
 						int fixup_node,
@@ -113,41 +203,49 @@ static int overlay_update_local_node_references(void *fdto,
 	int ret;
 
 	fdt_for_each_property_offset(fixup_prop, fdto, fixup_node) {
-		const uint32_t *val = NULL;
-		uint32_t adj_val, index;
+		const unsigned char *fixup_val, *tree_val;
 		const char *name;
 		int fixup_len;
 		int tree_len;
+		int i;
 
-		val = fdt_getprop_by_offset(fdto, fixup_prop,
-					    &name, &fixup_len);
-		if (!val)
+		fixup_val = fdt_getprop_by_offset(fdto, fixup_prop,
+						  &name, &fixup_len);
+		if (!fixup_val)
 			return fixup_len;
-		index = fdt32_to_cpu(*val);
 
-		val = fdt_getprop(fdto, tree_node, name, &tree_len);
-		if (!val)
+		tree_val = fdt_getprop(fdto, tree_node, name, &tree_len);
+		if (!tree_val)
 			return tree_len;
 
-		/*
-		 * The index can be unaligned.
-		 *
-		 * Use a memcpy for the architectures that do not
-		 * support unaligned accesses.
-		 */
-		memcpy(&adj_val, (unsigned char *)val + index,
-		       sizeof(uint32_t));
-
-		adj_val = fdt32_to_cpu(adj_val);
-		adj_val += delta;
-		adj_val = cpu_to_fdt32(adj_val);
-
-		ret = fdt_setprop_inplace_namelen_partial(fdto, tree_node,
-							  name, strlen(name),
-							  index, &adj_val,
-							  sizeof(adj_val));
-		if (ret)
-			return ret;
+		for (i = 0; i < fixup_len; i += sizeof(uint32_t)) {
+			uint32_t adj_val, index;
+
+			index = *(uint32_t *)(fixup_val + i);
+			index = fdt32_to_cpu(index);
+
+			/*
+			 * phandles to fixup can be unaligned.
+			 *
+			 * Use a memcpy for the architectures that do
+			 * not support unaligned accesses.
+			 */
+			memcpy(&adj_val, tree_val + index, sizeof(uint32_t));
+
+			adj_val = fdt32_to_cpu(adj_val);
+			adj_val += delta;
+			adj_val = cpu_to_fdt32(adj_val);
+
+			ret = fdt_setprop_inplace_namelen_partial(fdto,
+								  tree_node,
+								  name,
+								  strlen(name),
+								  index,
+								  &adj_val,
+								  sizeof(adj_val));
+			if (ret)
+				return ret;
+		}
 	}
 
 	fdt_for_each_subnode(fdto, fixup_child, fixup_node) {
@@ -171,11 +269,28 @@ static int overlay_update_local_node_references(void *fdto,
 	return 0;
 }
 
-static int overlay_update_local_references(void *dto, uint32_t delta)
+/**
+ * overlay_update_local_references - Adjust the overlay references
+ * @fdto: Device tree overlay blob
+ * @delta: Offset to shift the phandles of
+ *
+ * overlay_update_local_references() update all the phandles pointing
+ * to a node within the device tree overlay by adding a constant
+ * delta to not conflict with the base overlay.
+ *
+ * This is mainly used as part of a device tree application process,
+ * where you want the device tree overlays phandles to not conflict
+ * with the ones from the base device tree before merging them.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
+static int overlay_update_local_references(void *fdto, uint32_t delta)
 {
 	int fixups;
 
-	fixups = fdt_path_offset(dto, "/__local_fixups__");
+	fixups = fdt_path_offset(fdto, "/__local_fixups__");
 	if (fixups < 0) {
 		/* There's no local phandles to adjust, bail out */
 		if (fixups == -FDT_ERR_NOTFOUND)
@@ -187,10 +302,33 @@ static int overlay_update_local_references(void *dto, uint32_t delta)
 	/*
 	 * Update our local references from the root of the tree
 	 */
-	return overlay_update_local_node_references(dto, 0, fixups,
+	return overlay_update_local_node_references(fdto, 0, fixups,
 						    delta);
 }
 
+/**
+ * overlay_fixup_one_phandle - Set an overlay phandle to the base one
+ * @fdt: Base Device Tree blob
+ * @fdto: Device tree overlay blob
+ * @symbols_off: Node offset of the symbols node in the base device tree
+ * @path: Path to a node holding a phandle in the overlay
+ * @path_len: number of path characters to consider
+ * @name: Name of the property holding the phandle reference in the overlay
+ * @name_len: number of name characters to consider
+ * @index: Index in the overlay property where the phandle is stored
+ * @label: Label of the node referenced by the phandle
+ *
+ * overlay_fixup_one_phandle() resolves an overlay phandle pointing to
+ * a node in the base device tree.
+ *
+ * This is part of the device tree overlay application process, when
+ * you want all the phandles in the overlay to point to the actual
+ * base dt nodes.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
 static int overlay_fixup_one_phandle(void *fdt, void *fdto,
 				     int symbols_off,
 				     const char *path, uint32_t path_len,
@@ -225,6 +363,25 @@ static int overlay_fixup_one_phandle(void *fdt, void *fdto,
 						   &phandle, sizeof(phandle));
 };
 
+/**
+ * overlay_fixup_phandle - Set an overlay phandle to the base one
+ * @fdt: Base Device Tree blob
+ * @fdto: Device tree overlay blob
+ * @symbols_off: Node offset of the symbols node in the base device tree
+ * @property: Property offset in the overlay holding the list of fixups
+ *
+ * overlay_fixup_phandle() resolves all the overlay phandles pointed
+ * to in a __local_fixup__ property, and updates them to match the
+ * phandles in use in the base device tree.
+ *
+ * This is part of the device tree overlay application process, when
+ * you want all the phandles in the overlay to point to the actual
+ * base dt nodes.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
 static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
 				 int property)
 {
@@ -275,57 +432,98 @@ static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
 	return 0;
 }
 
-static int overlay_fixup_phandles(void *dt, void *dto)
+/**
+ * overlay_fixup_phandles - Resolve the overlay phandles to the base
+ *                          device tree
+ * @fdt: Base Device Tree blob
+ * @fdto: Device tree overlay blob
+ *
+ * overlay_fixup_phandles() resolves all the overlay phandles pointing
+ * to nodes in the base device tree.
+ *
+ * This is one of the steps of the device tree overlay application
+ * process, when you want all the phandles in the overlay to point to
+ * the actual base dt nodes.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
+static int overlay_fixup_phandles(void *fdt, void *fdto)
 {
 	int fixups_off, symbols_off;
 	int property;
 
-	symbols_off = fdt_path_offset(dt, "/__symbols__");
-	fixups_off = fdt_path_offset(dto, "/__fixups__");
+	symbols_off = fdt_path_offset(fdt, "/__symbols__");
+	fixups_off = fdt_path_offset(fdto, "/__fixups__");
+
+	fdt_for_each_property_offset(property, fdto, fixups_off) {
+		int ret;
 
-	fdt_for_each_property_offset(property, dto, fixups_off)
-		overlay_fixup_phandle(dt, dto, symbols_off, property);
+		ret = overlay_fixup_phandle(fdt, fdto, symbols_off, property);
+		if (ret)
+			return ret;
+	}
 
 	return 0;
 }
 
-static int apply_overlay_node(void *dt, int target,
-			      void *dto, int fragment)
+/**
+ * overlay_apply_node - Merge an overlay fragment into the base device tree
+ * @fdt: Base Device Tree blob
+ * @target: Node offset in the base device tree to apply the fragment to
+ * @fdto: Device tree overlay blob
+ * @fragment: Node offset in the overlay holding the changes to merge
+ *
+ * overlay_apply_node() merges an overlay fragment into a target base
+ * device tree node pointed.
+ *
+ * This is part of the final step in the device tree overlay
+ * application process, when all the phandles have been adjusted and
+ * resolved and you just have to merge overlay into the base device
+ * tree.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
+static int overlay_apply_node(void *fdt, int target,
+			      void *fdto, int fragment)
 {
 	int property;
 	int node;
 
-	fdt_for_each_property_offset(property, dto, fragment) {
+	fdt_for_each_property_offset(property, fdto, fragment) {
 		const char *name;
 		const void *prop;
 		int prop_len;
 		int ret;
 
-		prop = fdt_getprop_by_offset(dto, property, &name,
+		prop = fdt_getprop_by_offset(fdto, property, &name,
 					     &prop_len);
 		if (prop_len == -FDT_ERR_NOTFOUND)
 			return -FDT_ERR_INTERNAL;
 		if (prop_len < 0)
 			return prop_len;
 
-		ret = fdt_setprop(dt, target, name, prop, prop_len);
+		ret = fdt_setprop(fdt, target, name, prop, prop_len);
 		if (ret)
 			return ret;
 	}
 
-	fdt_for_each_subnode(dto, node, fragment) {
-		const char *name = fdt_get_name(dto, node, NULL);
+	fdt_for_each_subnode(fdto, node, fragment) {
+		const char *name = fdt_get_name(fdto, node, NULL);
 		int nnode;
 		int ret;
 
-		nnode = fdt_add_subnode(dt, target, name);
+		nnode = fdt_add_subnode(fdt, target, name);
 		if (nnode == -FDT_ERR_EXISTS)
-			nnode = fdt_subnode_offset(dt, target, name);
+			nnode = fdt_subnode_offset(fdt, target, name);
 
 		if (nnode < 0)
 			return nnode;
 
-		ret = apply_overlay_node(dt, nnode, dto, node);
+		ret = overlay_apply_node(fdt, nnode, fdto, node);
 		if (ret)
 			return ret;
 	}
@@ -333,6 +531,21 @@ static int apply_overlay_node(void *dt, int target,
 	return 0;
 }
 
+/**
+ * overlay_merge - Merge an overlay into its base device tree
+ * @fdt: Base Device Tree blob
+ * @fdto: Device tree overlay blob
+ *
+ * overlay_merge() merges an overlay into its base device tree.
+ *
+ * This is the final step in the device tree overlay application
+ * process, when all the phandles have been adjusted and resolved and
+ * you just have to merge overlay into the base device tree.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
 static int overlay_merge(void *dt, void *dto)
 {
 	int fragment;
@@ -350,7 +563,7 @@ static int overlay_merge(void *dt, void *dto)
 		if (overlay < 0)
 			return overlay;
 
-		ret = apply_overlay_node(dt, target, dto, overlay);
+		ret = overlay_apply_node(dt, target, dto, overlay);
 		if (ret)
 			return ret;
 	}
diff --git a/test/Kconfig b/test/Kconfig
index d71c332eee27..3643761bc6ef 100644
--- a/test/Kconfig
+++ b/test/Kconfig
@@ -17,3 +17,4 @@ config UT_TIME
 
 source "test/dm/Kconfig"
 source "test/env/Kconfig"
+source "test/overlay/Kconfig"
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index f6e1f413db7f..14333423a178 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -19,6 +19,9 @@ static cmd_tbl_t cmd_ut_sub[] = {
 #if defined(CONFIG_UT_ENV)
 	U_BOOT_CMD_MKENT(env, CONFIG_SYS_MAXARGS, 1, do_ut_env, "", ""),
 #endif
+#ifdef CONFIG_UT_OVERLAY
+	U_BOOT_CMD_MKENT(overlay, CONFIG_SYS_MAXARGS, 1, do_ut_overlay, "", ""),
+#endif
 #ifdef CONFIG_UT_TIME
 	U_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, "", ""),
 #endif
@@ -68,6 +71,9 @@ static char ut_help_text[] =
 #ifdef CONFIG_UT_ENV
 	"ut env [test-name]\n"
 #endif
+#ifdef CONFIG_UT_OVERLAY
+	"ut overlay [test-name]\n"
+#endif
 #ifdef CONFIG_UT_TIME
 	"ut time - Very basic test of time functions\n"
 #endif
diff --git a/test/overlay/Kconfig b/test/overlay/Kconfig
new file mode 100644
index 000000000000..13c85428cbaa
--- /dev/null
+++ b/test/overlay/Kconfig
@@ -0,0 +1,11 @@
+config UT_OVERLAY
+	bool "Enable Device Tree Overlays Unit Tests"
+	depends on OF_LIBFDT_OVERLAY
+	depends on UNIT_TEST
+	help
+	  This enables the 'ut overlay' command which runs a series of unit
+	  tests on the fdt overlay code.
+	  If all is well then all tests pass although there will be a few
+	  messages printed along the way.
+	  Be warned that it requires an out-of-tree dtc compiler with patches
+	  to support the DT overlays, otherwise it will fail.
diff --git a/test/overlay/Makefile b/test/overlay/Makefile
new file mode 100644
index 000000000000..907f08544619
--- /dev/null
+++ b/test/overlay/Makefile
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2016 NextThing Co
+# Copyright (c) 2016 Free Electrons
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+# Test files
+obj-y += cmd_ut_overlay.o
+
+DTC_FLAGS += -@
+
+# DT overlays
+obj-y += test-fdt-base.dtb.o
+obj-y += test-fdt-overlay.dtb.o
diff --git a/test/overlay/cmd_ut_overlay.c b/test/overlay/cmd_ut_overlay.c
new file mode 100644
index 000000000000..87dc9328c674
--- /dev/null
+++ b/test/overlay/cmd_ut_overlay.c
@@ -0,0 +1,268 @@
+/*
+ * Copyright (c) 2016 NextThing Co
+ * Copyright (c) 2016 Free Electrons
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <command.h>
+#include <errno.h>
+#include <malloc.h>
+
+#include <linux/sizes.h>
+
+#include <test/ut.h>
+#include <test/overlay.h>
+
+/* 4k ought to be enough for anybody */
+#define FDT_COPY_SIZE	(4 * SZ_1K)
+
+extern u32 __dtb_test_fdt_base_begin;
+extern u32 __dtb_test_fdt_overlay_begin;
+
+static int fdt_getprop_u32_by_index(void *fdt, const char *path,
+				    const char *name, int index,
+				    u32 *out)
+{
+	const fdt32_t *val;
+	int node_off;
+	int len;
+
+	node_off = fdt_path_offset(fdt, path);
+	if (node_off < 0)
+		return node_off;
+
+	val = fdt_getprop(fdt, node_off, name, &len);
+	if (!val || (len < (sizeof(uint32_t) * (index + 1))))
+		return -FDT_ERR_NOTFOUND;
+
+	*out = fdt32_to_cpu(*(val + index));
+
+	return 0;
+}
+
+static int fdt_getprop_u32(void *fdt, const char *path, const char *name,
+			   u32 *out)
+{
+	return fdt_getprop_u32_by_index(fdt, path, name, 0, out);
+}
+
+static int fdt_getprop_str(void *fdt, const char *path, const char *name,
+			   const char **out)
+{
+	int node_off;
+
+	node_off = fdt_path_offset(fdt, path);
+	if (node_off < 0)
+		return node_off;
+
+	return fdt_get_string(fdt, node_off, name, out);
+}
+
+static int fdt_overlay_change_int_property(struct unit_test_state *uts)
+{
+	void *fdt = uts->priv;
+	u32 val = 0;
+
+	ut_assertok(fdt_getprop_u32(fdt, "/test-node", "test-int-property",
+				    &val));
+	ut_asserteq(43, val);
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_change_int_property, 0);
+
+static int fdt_overlay_change_str_property(struct unit_test_state *uts)
+{
+	void *fdt = uts->priv;
+	const char *val = NULL;
+
+	ut_assertok(fdt_getprop_str(fdt, "/test-node", "test-str-property",
+				    &val));
+	ut_asserteq_str("foobar", val);
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_change_str_property, 0);
+
+static int fdt_overlay_add_str_property(struct unit_test_state *uts)
+{
+	void *fdt = uts->priv;
+	const char *val = NULL;
+
+	ut_assertok(fdt_getprop_str(fdt, "/test-node", "test-str-property-2",
+				    &val));
+	ut_asserteq_str("foobar2", val);
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_add_str_property, 0);
+
+static int fdt_overlay_add_node_by_phandle(struct unit_test_state *uts)
+{
+	void *fdt = uts->priv;
+	int off;
+
+	off = fdt_path_offset(fdt, "/test-node/new-node");
+	ut_assert(off >= 0);
+
+	ut_assertnonnull(fdt_getprop(fdt, off, "new-property", NULL));
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_add_node_by_phandle, 0);
+
+static int fdt_overlay_add_node_by_path(struct unit_test_state *uts)
+{
+	void *fdt = uts->priv;
+	int off;
+
+	off = fdt_path_offset(fdt, "/new-node");
+	ut_assert(off >= 0);
+
+	ut_assertnonnull(fdt_getprop(fdt, off, "new-property", NULL));
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_add_node_by_path, 0);
+
+static int fdt_overlay_add_subnode_property(struct unit_test_state *uts)
+{
+	void *fdt = uts->priv;
+	int off;
+
+	off = fdt_path_offset(fdt, "/test-node/sub-test-node");
+	ut_assert(off >= 0);
+
+	ut_assertnonnull(fdt_getprop(fdt, off, "sub-test-property", NULL));
+	ut_assertnonnull(fdt_getprop(fdt, off, "new-sub-test-property", NULL));
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_add_subnode_property, 0);
+
+static int fdt_overlay_local_phandle(struct unit_test_state *uts)
+{
+	uint32_t local_phandle;
+	void *fdt = uts->priv;
+	u32 val = 0;
+	int off;
+
+	off = fdt_path_offset(fdt, "/new-local-node");
+	ut_assert(off >= 0);
+
+	local_phandle = fdt_get_phandle(fdt, off);
+	ut_assert(local_phandle);
+
+	ut_assertok(fdt_getprop_u32_by_index(fdt, "/", "test-several-phandle",
+					     0, &val));
+	ut_asserteq(local_phandle, val);
+
+	ut_assertok(fdt_getprop_u32_by_index(fdt, "/", "test-several-phandle",
+					     1, &val));
+	ut_asserteq(local_phandle, val);
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_local_phandle, 0);
+
+static int fdt_overlay_local_phandles(struct unit_test_state *uts)
+{
+	uint32_t local_phandle, test_phandle;
+	void *fdt = uts->priv;
+	u32 val = 0;
+	int off;
+
+	off = fdt_path_offset(fdt, "/new-local-node");
+	ut_assert(off >= 0);
+
+	local_phandle = fdt_get_phandle(fdt, off);
+	ut_assert(local_phandle);
+
+	off = fdt_path_offset(fdt, "/test-node");
+	ut_assert(off >= 0);
+
+	test_phandle = fdt_get_phandle(fdt, off);
+	ut_assert(test_phandle);
+
+	ut_assertok(fdt_getprop_u32_by_index(fdt, "/", "test-phandle", 0,
+					     &val));
+	ut_asserteq(test_phandle, val);
+
+	ut_assertok(fdt_getprop_u32_by_index(fdt, "/", "test-phandle", 1,
+					     &val));
+	ut_asserteq(local_phandle, val);
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_local_phandles, 0);
+
+int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	struct unit_test *tests = ll_entry_start(struct unit_test,
+						 overlay_test);
+	const int n_ents = ll_entry_count(struct unit_test, overlay_test);
+	struct unit_test_state *uts;
+	struct unit_test *test;
+	void *fdt_base = &__dtb_test_fdt_base_begin;
+	void *fdt_overlay = &__dtb_test_fdt_overlay_begin;
+	void *fdt_base_copy, *fdt_overlay_copy;
+
+	uts = calloc(1, sizeof(*uts));
+	if (!uts)
+		return -ENOMEM;
+
+	ut_assertok(fdt_check_header(fdt_base));
+	ut_assertok(fdt_check_header(fdt_overlay));
+
+	fdt_base_copy = malloc(FDT_COPY_SIZE);
+	if (!fdt_base_copy)
+		return -ENOMEM;
+	uts->priv = fdt_base_copy;
+
+	fdt_overlay_copy = malloc(FDT_COPY_SIZE);
+	if (!fdt_overlay_copy)
+		return -ENOMEM;
+
+	/*
+	 * Resize the FDT to 4k so that we have room to operate on
+	 *
+	 * (and relocate it since the memory might be mapped
+	 * read-only)
+	 */
+	ut_assertok(fdt_open_into(fdt_base, fdt_base_copy, FDT_COPY_SIZE));
+
+	/*
+	 * Resize the overlay to 4k so that we have room to operate on
+	 *
+	 * (and relocate it since the memory might be mapped
+	 * read-only)
+	 */
+	ut_assertok(fdt_open_into(fdt_overlay, fdt_overlay_copy,
+				  FDT_COPY_SIZE));
+
+	/* Apply the overlay */
+	ut_assertok(fdt_overlay_apply(fdt_base_copy, fdt_overlay_copy));
+
+	if (argc == 1)
+		printf("Running %d environment tests\n", n_ents);
+
+	for (test = tests; test < tests + n_ents; test++) {
+		if (argc > 1 && strcmp(argv[1], test->name))
+			continue;
+		printf("Test: %s\n", test->name);
+
+		uts->start = mallinfo();
+
+		test->func(uts);
+	}
+
+	printf("Failures: %d\n", uts->fail_count);
+
+	free(fdt_overlay_copy);
+	free(fdt_base_copy);
+	free(uts);
+
+	return uts->fail_count ? CMD_RET_FAILURE : 0;
+}
diff --git a/test/overlay/test-fdt-base.dts b/test/overlay/test-fdt-base.dts
new file mode 100644
index 000000000000..2603adb6821e
--- /dev/null
+++ b/test/overlay/test-fdt-base.dts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2016 NextThing Co
+ * Copyright (c) 2016 Free Electrons
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+/dts-v1/;
+
+/ {
+	test: test-node {
+		test-int-property = <42>;
+		test-str-property = "foo";
+
+		subtest: sub-test-node {
+			sub-test-property;
+		};
+	};
+};
+
+
diff --git a/test/overlay/test-fdt-overlay.dts b/test/overlay/test-fdt-overlay.dts
new file mode 100644
index 000000000000..d30ecdf3661c
--- /dev/null
+++ b/test/overlay/test-fdt-overlay.dts
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2016 NextThing Co
+ * Copyright (c) 2016 Free Electrons
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+/dts-v1/;
+/plugin/;
+
+/ {
+	/* Test that we can change an int by another */
+	fragment@0 {
+		target = <&test>;
+
+		__overlay__ {
+			test-int-property = <43>;
+		};
+	};
+
+	/* Test that we can replace a string by a longer one */
+	fragment@1 {
+		target = <&test>;
+
+		__overlay__ {
+			test-str-property = "foobar";
+		};
+	};
+
+	/* Test that we add a new property */
+	fragment@2 {
+		target = <&test>;
+
+		__overlay__ {
+			test-str-property-2 = "foobar2";
+		};
+	};
+
+	/* Test that we add a new node (by phandle) */
+	fragment@3 {
+		target = <&test>;
+
+		__overlay__ {
+			new-node {
+				new-property;
+			};
+		};
+	};
+
+	/* Test that we add a new node (by path) */
+	fragment@4 {
+		target-path = "/";
+
+		__overlay__ {
+			new-node {
+				new-property;
+			};
+		};
+	};
+
+	fragment@5 {
+		target-path = "/";
+
+		__overlay__ {
+			local: new-local-node {
+				new-property;
+			};
+		};
+	};
+
+	fragment@6 {
+		target-path = "/";
+
+		__overlay__ {
+			test-phandle = <&test>, <&local>;
+		};
+	};
+
+	fragment@7 {
+		target-path = "/";
+
+		__overlay__ {
+			test-several-phandle = <&local>, <&local>;
+		};
+	};
+
+	fragment@8 {
+		target = <&test>;
+
+		__overlay__ {
+			sub-test-node {
+				new-sub-test-property;
+			};
+		};
+	};
+};
-- 
2.9.0

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

* [U-Boot] [PATCH v4 06/13] libfdt: Add max phandle retrieval function
@ 2016-07-06  1:13     ` David Gibson
  0 siblings, 0 replies; 76+ messages in thread
From: David Gibson @ 2016-07-06  1:13 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 05, 2016 at 10:26:39AM +0200, Maxime Ripard wrote:
> Add a function to retrieve the highest phandle in a given device tree.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> Reviewed-by: Stefan Agner <stefan@agner.ch>
> Acked-by: Simon Glass <sjg@chromium.org>
> ---
>  include/libfdt.h    | 13 +++++++++++++
>  lib/libfdt/fdt_ro.c | 26 ++++++++++++++++++++++++++
>  2 files changed, 39 insertions(+)
> 
> diff --git a/include/libfdt.h b/include/libfdt.h
> index fbbe58ceb3f1..4643be5adf39 100644
> --- a/include/libfdt.h
> +++ b/include/libfdt.h
> @@ -283,6 +283,19 @@ int fdt_move(const void *fdt, void *buf, int bufsize);
>   */
>  const char *fdt_string(const void *fdt, int stroffset);
>  
> +/**
> + * fdt_get_max_phandle - retrieves the highest phandle in a tree
> + * @fdt: pointer to the device tree blob
> + *
> + * fdt_get_max_phandle retrieves the highest phandle in the given
> + * device tree
> + *
> + * returns:
> + *      the highest phandle on success
> + *      0, if an error occurred

This will also return 0 if there are no phandles in the entire tree,
which isn't exactly an error.

> + */
> +uint32_t fdt_get_max_phandle(const void *fdt);
> +
>  /**
>   * fdt_num_mem_rsv - retrieve the number of memory reserve map entries
>   * @fdt: pointer to the device tree blob
> diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
> index 12214c2dc2b5..503150ef1dc5 100644
> --- a/lib/libfdt/fdt_ro.c
> +++ b/lib/libfdt/fdt_ro.c
> @@ -47,6 +47,32 @@ static int _fdt_string_eq(const void *fdt, int stroffset,
>  	return (strnlen(p, len + 1) == len) && (memcmp(p, s, len) == 0);
>  }
>  
> +uint32_t fdt_get_max_phandle(const void *fdt)
> +{
> +	uint32_t max_phandle = 0;
> +	int offset;
> +
> +	for (offset = fdt_next_node(fdt, -1, NULL);;
> +	     offset = fdt_next_node(fdt, offset, NULL)) {
> +		uint32_t phandle;
> +
> +		if (offset == -FDT_ERR_NOTFOUND)
> +			return max_phandle;
> +
> +		if (offset < 0)
> +			return 0;
> +
> +		phandle = fdt_get_phandle(fdt, offset);
> +		if (phandle == (uint32_t)-1)
> +			return 0;

It might be worth pointing out that *any* -1 phandle in the tree
counts as an error.  Since -1 phandles are sometimes used as a
placeholder, ignoring them might be a better option.

> +		if (phandle > max_phandle)
> +			max_phandle = phandle;
> +	}
> +
> +	return 0;
> +}
> +
>  int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
>  {
>  	FDT_CHECK_HEADER(fdt);

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160706/6045f04f/attachment.sig>

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

* Re: [PATCH v4 06/13] libfdt: Add max phandle retrieval function
@ 2016-07-06  1:13     ` David Gibson
  0 siblings, 0 replies; 76+ messages in thread
From: David Gibson @ 2016-07-06  1:13 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Boris Brezillon,
	Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner

[-- Attachment #1: Type: text/plain, Size: 2820 bytes --]

On Tue, Jul 05, 2016 at 10:26:39AM +0200, Maxime Ripard wrote:
> Add a function to retrieve the highest phandle in a given device tree.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> Reviewed-by: Stefan Agner <stefan-XLVq0VzYD2Y@public.gmane.org>
> Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> ---
>  include/libfdt.h    | 13 +++++++++++++
>  lib/libfdt/fdt_ro.c | 26 ++++++++++++++++++++++++++
>  2 files changed, 39 insertions(+)
> 
> diff --git a/include/libfdt.h b/include/libfdt.h
> index fbbe58ceb3f1..4643be5adf39 100644
> --- a/include/libfdt.h
> +++ b/include/libfdt.h
> @@ -283,6 +283,19 @@ int fdt_move(const void *fdt, void *buf, int bufsize);
>   */
>  const char *fdt_string(const void *fdt, int stroffset);
>  
> +/**
> + * fdt_get_max_phandle - retrieves the highest phandle in a tree
> + * @fdt: pointer to the device tree blob
> + *
> + * fdt_get_max_phandle retrieves the highest phandle in the given
> + * device tree
> + *
> + * returns:
> + *      the highest phandle on success
> + *      0, if an error occurred

This will also return 0 if there are no phandles in the entire tree,
which isn't exactly an error.

> + */
> +uint32_t fdt_get_max_phandle(const void *fdt);
> +
>  /**
>   * fdt_num_mem_rsv - retrieve the number of memory reserve map entries
>   * @fdt: pointer to the device tree blob
> diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
> index 12214c2dc2b5..503150ef1dc5 100644
> --- a/lib/libfdt/fdt_ro.c
> +++ b/lib/libfdt/fdt_ro.c
> @@ -47,6 +47,32 @@ static int _fdt_string_eq(const void *fdt, int stroffset,
>  	return (strnlen(p, len + 1) == len) && (memcmp(p, s, len) == 0);
>  }
>  
> +uint32_t fdt_get_max_phandle(const void *fdt)
> +{
> +	uint32_t max_phandle = 0;
> +	int offset;
> +
> +	for (offset = fdt_next_node(fdt, -1, NULL);;
> +	     offset = fdt_next_node(fdt, offset, NULL)) {
> +		uint32_t phandle;
> +
> +		if (offset == -FDT_ERR_NOTFOUND)
> +			return max_phandle;
> +
> +		if (offset < 0)
> +			return 0;
> +
> +		phandle = fdt_get_phandle(fdt, offset);
> +		if (phandle == (uint32_t)-1)
> +			return 0;

It might be worth pointing out that *any* -1 phandle in the tree
counts as an error.  Since -1 phandles are sometimes used as a
placeholder, ignoring them might be a better option.

> +		if (phandle > max_phandle)
> +			max_phandle = phandle;
> +	}
> +
> +	return 0;
> +}
> +
>  int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
>  {
>  	FDT_CHECK_HEADER(fdt);

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [PATCH v4 07/13] libfdt: Fix separator spelling
@ 2016-07-06  1:16     ` David Gibson
  0 siblings, 0 replies; 76+ messages in thread
From: David Gibson @ 2016-07-06  1:16 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 05, 2016 at 10:26:40AM +0200, Maxime Ripard wrote:
> The function fdt_path_next_seperator had an obvious mispell. Fix it.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Huh.. this entire function appears not to be in upstream libfdt.

> ---
>  lib/libfdt/fdt_ro.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
> index 503150ef1dc5..6b737b211d2e 100644
> --- a/lib/libfdt/fdt_ro.c
> +++ b/lib/libfdt/fdt_ro.c
> @@ -140,12 +140,12 @@ int fdt_subnode_offset(const void *fdt, int parentoffset,
>  }
>  
>  /*
> - * Find the next of path seperator, note we need to search for both '/' and ':'
> + * Find the next of path separator, note we need to search for both '/' and ':'
>   * and then take the first one so that we do the right thing for e.g.
>   * "foo/bar:option" and "bar:option/otheroption", both of which happen, so
>   * first searching for either ':' or '/' does not work.
>   */
> -static const char *fdt_path_next_seperator(const char *path)
> +static const char *fdt_path_next_separator(const char *path)
>  {
>  	const char *sep1 = strchr(path, '/');
>  	const char *sep2 = strchr(path, ':');
> @@ -168,7 +168,7 @@ int fdt_path_offset(const void *fdt, const char *path)
>  
>  	/* see if we have an alias */
>  	if (*path != '/') {
> -		const char *q = fdt_path_next_seperator(path);
> +		const char *q = fdt_path_next_separator(path);
>  
>  		if (!q)
>  			q = end;
> @@ -188,7 +188,7 @@ int fdt_path_offset(const void *fdt, const char *path)
>  			p++;
>  		if (*p == '\0' || *p == ':')
>  			return offset;
> -		q = fdt_path_next_seperator(p);
> +		q = fdt_path_next_separator(p);
>  		if (!q)
>  			q = end;
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160706/f2f739a3/attachment.sig>

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

* Re: [PATCH v4 07/13] libfdt: Fix separator spelling
@ 2016-07-06  1:16     ` David Gibson
  0 siblings, 0 replies; 76+ messages in thread
From: David Gibson @ 2016-07-06  1:16 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Boris Brezillon,
	Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner

[-- Attachment #1: Type: text/plain, Size: 2017 bytes --]

On Tue, Jul 05, 2016 at 10:26:40AM +0200, Maxime Ripard wrote:
> The function fdt_path_next_seperator had an obvious mispell. Fix it.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Huh.. this entire function appears not to be in upstream libfdt.

> ---
>  lib/libfdt/fdt_ro.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
> index 503150ef1dc5..6b737b211d2e 100644
> --- a/lib/libfdt/fdt_ro.c
> +++ b/lib/libfdt/fdt_ro.c
> @@ -140,12 +140,12 @@ int fdt_subnode_offset(const void *fdt, int parentoffset,
>  }
>  
>  /*
> - * Find the next of path seperator, note we need to search for both '/' and ':'
> + * Find the next of path separator, note we need to search for both '/' and ':'
>   * and then take the first one so that we do the right thing for e.g.
>   * "foo/bar:option" and "bar:option/otheroption", both of which happen, so
>   * first searching for either ':' or '/' does not work.
>   */
> -static const char *fdt_path_next_seperator(const char *path)
> +static const char *fdt_path_next_separator(const char *path)
>  {
>  	const char *sep1 = strchr(path, '/');
>  	const char *sep2 = strchr(path, ':');
> @@ -168,7 +168,7 @@ int fdt_path_offset(const void *fdt, const char *path)
>  
>  	/* see if we have an alias */
>  	if (*path != '/') {
> -		const char *q = fdt_path_next_seperator(path);
> +		const char *q = fdt_path_next_separator(path);
>  
>  		if (!q)
>  			q = end;
> @@ -188,7 +188,7 @@ int fdt_path_offset(const void *fdt, const char *path)
>  			p++;
>  		if (*p == '\0' || *p == ':')
>  			return offset;
> -		q = fdt_path_next_seperator(p);
> +		q = fdt_path_next_separator(p);
>  		if (!q)
>  			q = end;
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [PATCH v4 08/13] libfdt: Add fdt_path_offset_namelen
@ 2016-07-06  1:21     ` David Gibson
  0 siblings, 0 replies; 76+ messages in thread
From: David Gibson @ 2016-07-06  1:21 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 05, 2016 at 10:26:41AM +0200, Maxime Ripard wrote:
> Add a namelen variant of fdt_path_offset to retrieve the node offset using
> only a fixed number of characters.
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
>  include/libfdt.h    | 16 +++++++++++++++-
>  lib/libfdt/fdt_ro.c | 18 ++++++++++--------
>  2 files changed, 25 insertions(+), 9 deletions(-)
> 
> diff --git a/include/libfdt.h b/include/libfdt.h
> index 4643be5adf39..f13b01f08f71 100644
> --- a/include/libfdt.h
> +++ b/include/libfdt.h
> @@ -365,6 +365,17 @@ int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
>   */
>  int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
>  
> +/**
> + * fdt_path_offset_namelen - find a tree node based on substring
> + * @fdt: pointer to the device tree blob
> + * @path: full path of the node to locate
> + * @namelen: number of characters of name to consider
> + *
> + * Identical to fdt_path_offset(), but only examine the first
> + * namelen characters of path for matching the node path.
> + */
> +int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
> +
>  /**
>   * fdt_path_offset - find a tree node by its full path
>   * @fdt: pointer to the device tree blob
> @@ -387,7 +398,10 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
>   *	-FDT_ERR_BADSTRUCTURE,
>   *	-FDT_ERR_TRUNCATED, standard meanings.
>   */
> -int fdt_path_offset(const void *fdt, const char *path);
> +static inline int fdt_path_offset(const void *fdt, const char *path)
> +{
> +	return fdt_path_offset_namelen(fdt, path, strlen(path));
> +}
>  
>  /**
>   * fdt_get_name - retrieve the name of a given node
> diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
> index 6b737b211d2e..9cc98db6e2bf 100644
> --- a/lib/libfdt/fdt_ro.c
> +++ b/lib/libfdt/fdt_ro.c
> @@ -145,10 +145,10 @@ int fdt_subnode_offset(const void *fdt, int parentoffset,
>   * "foo/bar:option" and "bar:option/otheroption", both of which happen, so
>   * first searching for either ':' or '/' does not work.
>   */
> -static const char *fdt_path_next_separator(const char *path)
> +static const char *fdt_path_next_separator(const char *path, int len)
>  {
> -	const char *sep1 = strchr(path, '/');
> -	const char *sep2 = strchr(path, ':');
> +	const void *sep1 = memchr(path, '/', len);
> +	const void *sep2 = memchr(path, ':', len);
>  
>  	if (sep1 && sep2)
>  		return (sep1 < sep2) ? sep1 : sep2;
> @@ -158,9 +158,9 @@ static const char *fdt_path_next_separator(const char *path)
>  		return sep2;
>  }
>  
> -int fdt_path_offset(const void *fdt, const char *path)
> +int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen)
>  {
> -	const char *end = path + strlen(path);
> +	const char *end = path + namelen;
>  	const char *p = path;
>  	int offset = 0;
>  
> @@ -168,7 +168,7 @@ int fdt_path_offset(const void *fdt, const char *path)
>  
>  	/* see if we have an alias */
>  	if (*path != '/') {
> -		const char *q = fdt_path_next_separator(path);
> +		const char *q = fdt_path_next_separator(path, namelen);
>  
>  		if (!q)
>  			q = end;
> @@ -181,14 +181,16 @@ int fdt_path_offset(const void *fdt, const char *path)
>  		p = q;
>  	}
>  
> -	while (*p) {
> +	while (*p && (p < end)) {

The *p test should now be redundant.  If you do see a \0 within the
length specified by namelen, you should return FDT_ERR_BADPATH, rather
than just truncating@the \0.

... and I just realised that path_offset_namelen() is already
upstream, so I should fix that there too.

So what the hell is this downstream fdt_path_next_separator() nonsense for?

>  		const char *q;
>  
>  		while (*p == '/')
>  			p++;
> +
>  		if (*p == '\0' || *p == ':')
>  			return offset;
> -		q = fdt_path_next_separator(p);
> +
> +		q = fdt_path_next_separator(p, end - p);
>  		if (!q)
>  			q = end;
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160706/666fc7cc/attachment.sig>

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

* Re: [PATCH v4 08/13] libfdt: Add fdt_path_offset_namelen
@ 2016-07-06  1:21     ` David Gibson
  0 siblings, 0 replies; 76+ messages in thread
From: David Gibson @ 2016-07-06  1:21 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Boris Brezillon,
	Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner

[-- Attachment #1: Type: text/plain, Size: 4312 bytes --]

On Tue, Jul 05, 2016 at 10:26:41AM +0200, Maxime Ripard wrote:
> Add a namelen variant of fdt_path_offset to retrieve the node offset using
> only a fixed number of characters.
> 
> Reviewed-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
>  include/libfdt.h    | 16 +++++++++++++++-
>  lib/libfdt/fdt_ro.c | 18 ++++++++++--------
>  2 files changed, 25 insertions(+), 9 deletions(-)
> 
> diff --git a/include/libfdt.h b/include/libfdt.h
> index 4643be5adf39..f13b01f08f71 100644
> --- a/include/libfdt.h
> +++ b/include/libfdt.h
> @@ -365,6 +365,17 @@ int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
>   */
>  int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
>  
> +/**
> + * fdt_path_offset_namelen - find a tree node based on substring
> + * @fdt: pointer to the device tree blob
> + * @path: full path of the node to locate
> + * @namelen: number of characters of name to consider
> + *
> + * Identical to fdt_path_offset(), but only examine the first
> + * namelen characters of path for matching the node path.
> + */
> +int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
> +
>  /**
>   * fdt_path_offset - find a tree node by its full path
>   * @fdt: pointer to the device tree blob
> @@ -387,7 +398,10 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
>   *	-FDT_ERR_BADSTRUCTURE,
>   *	-FDT_ERR_TRUNCATED, standard meanings.
>   */
> -int fdt_path_offset(const void *fdt, const char *path);
> +static inline int fdt_path_offset(const void *fdt, const char *path)
> +{
> +	return fdt_path_offset_namelen(fdt, path, strlen(path));
> +}
>  
>  /**
>   * fdt_get_name - retrieve the name of a given node
> diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
> index 6b737b211d2e..9cc98db6e2bf 100644
> --- a/lib/libfdt/fdt_ro.c
> +++ b/lib/libfdt/fdt_ro.c
> @@ -145,10 +145,10 @@ int fdt_subnode_offset(const void *fdt, int parentoffset,
>   * "foo/bar:option" and "bar:option/otheroption", both of which happen, so
>   * first searching for either ':' or '/' does not work.
>   */
> -static const char *fdt_path_next_separator(const char *path)
> +static const char *fdt_path_next_separator(const char *path, int len)
>  {
> -	const char *sep1 = strchr(path, '/');
> -	const char *sep2 = strchr(path, ':');
> +	const void *sep1 = memchr(path, '/', len);
> +	const void *sep2 = memchr(path, ':', len);
>  
>  	if (sep1 && sep2)
>  		return (sep1 < sep2) ? sep1 : sep2;
> @@ -158,9 +158,9 @@ static const char *fdt_path_next_separator(const char *path)
>  		return sep2;
>  }
>  
> -int fdt_path_offset(const void *fdt, const char *path)
> +int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen)
>  {
> -	const char *end = path + strlen(path);
> +	const char *end = path + namelen;
>  	const char *p = path;
>  	int offset = 0;
>  
> @@ -168,7 +168,7 @@ int fdt_path_offset(const void *fdt, const char *path)
>  
>  	/* see if we have an alias */
>  	if (*path != '/') {
> -		const char *q = fdt_path_next_separator(path);
> +		const char *q = fdt_path_next_separator(path, namelen);
>  
>  		if (!q)
>  			q = end;
> @@ -181,14 +181,16 @@ int fdt_path_offset(const void *fdt, const char *path)
>  		p = q;
>  	}
>  
> -	while (*p) {
> +	while (*p && (p < end)) {

The *p test should now be redundant.  If you do see a \0 within the
length specified by namelen, you should return FDT_ERR_BADPATH, rather
than just truncating at the \0.

... and I just realised that path_offset_namelen() is already
upstream, so I should fix that there too.

So what the hell is this downstream fdt_path_next_separator() nonsense for?

>  		const char *q;
>  
>  		while (*p == '/')
>  			p++;
> +
>  		if (*p == '\0' || *p == ':')
>  			return offset;
> -		q = fdt_path_next_separator(p);
> +
> +		q = fdt_path_next_separator(p, end - p);
>  		if (!q)
>  			q = end;
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [PATCH v4 09/13] libfdt: Add fdt_getprop_namelen_w
@ 2016-07-06  1:22     ` David Gibson
  0 siblings, 0 replies; 76+ messages in thread
From: David Gibson @ 2016-07-06  1:22 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 05, 2016 at 10:26:42AM +0200, Maxime Ripard wrote:
> Add a function to retrieve a writeable property only by the first
> characters of its name.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

This shouldn't be exported, so it should go into libfdt_internal.h.

> ---
>  include/libfdt.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/include/libfdt.h b/include/libfdt.h
> index f13b01f08f71..a55d2d0d8c7b 100644
> --- a/include/libfdt.h
> +++ b/include/libfdt.h
> @@ -619,6 +619,13 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
>   */
>  const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
>  				const char *name, int namelen, int *lenp);
> +static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
> +					  const char *name, int namelen,
> +					  int *lenp)
> +{
> +	return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
> +						      namelen, lenp);

uintptr_t ??

> +}
>  
>  /**
>   * fdt_getprop - retrieve the value of a given property

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160706/8ed66a28/attachment.sig>

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

* Re: [PATCH v4 09/13] libfdt: Add fdt_getprop_namelen_w
@ 2016-07-06  1:22     ` David Gibson
  0 siblings, 0 replies; 76+ messages in thread
From: David Gibson @ 2016-07-06  1:22 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Boris Brezillon,
	Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner

[-- Attachment #1: Type: text/plain, Size: 1319 bytes --]

On Tue, Jul 05, 2016 at 10:26:42AM +0200, Maxime Ripard wrote:
> Add a function to retrieve a writeable property only by the first
> characters of its name.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

This shouldn't be exported, so it should go into libfdt_internal.h.

> ---
>  include/libfdt.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/include/libfdt.h b/include/libfdt.h
> index f13b01f08f71..a55d2d0d8c7b 100644
> --- a/include/libfdt.h
> +++ b/include/libfdt.h
> @@ -619,6 +619,13 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
>   */
>  const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
>  				const char *name, int namelen, int *lenp);
> +static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
> +					  const char *name, int namelen,
> +					  int *lenp)
> +{
> +	return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
> +						      namelen, lenp);

uintptr_t ??

> +}
>  
>  /**
>   * fdt_getprop - retrieve the value of a given property

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [PATCH v4 07/13] libfdt: Fix separator spelling
@ 2016-07-11  6:59       ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-11  6:59 UTC (permalink / raw)
  To: u-boot

Hi David,

On Wed, Jul 06, 2016 at 11:16:41AM +1000, David Gibson wrote:
> On Tue, Jul 05, 2016 at 10:26:40AM +0200, Maxime Ripard wrote:
> > The function fdt_path_next_seperator had an obvious mispell. Fix it.
> > 
> > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> 
> Huh.. this entire function appears not to be in upstream libfdt.

Indeed, it was introduced in this commit:
http://git.denx.de/?p=u-boot.git;a=commit;h=77d7fff8cec2652be8c2494b6b66d14a398ec860

I have no idea why it wasn't upstreamed.

I'll make it part of my serie for libfdt.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160711/505819b1/attachment.sig>

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

* Re: [PATCH v4 07/13] libfdt: Fix separator spelling
@ 2016-07-11  6:59       ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-11  6:59 UTC (permalink / raw)
  To: David Gibson
  Cc: Pantelis Antoniou, Simon Glass, Boris Brezillon,
	Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner

[-- Attachment #1: Type: text/plain, Size: 728 bytes --]

Hi David,

On Wed, Jul 06, 2016 at 11:16:41AM +1000, David Gibson wrote:
> On Tue, Jul 05, 2016 at 10:26:40AM +0200, Maxime Ripard wrote:
> > The function fdt_path_next_seperator had an obvious mispell. Fix it.
> > 
> > Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> 
> Huh.. this entire function appears not to be in upstream libfdt.

Indeed, it was introduced in this commit:
http://git.denx.de/?p=u-boot.git;a=commit;h=77d7fff8cec2652be8c2494b6b66d14a398ec860

I have no idea why it wasn't upstreamed.

I'll make it part of my serie for libfdt.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [PATCH v4 09/13] libfdt: Add fdt_getprop_namelen_w
  2016-07-06  1:22     ` David Gibson
@ 2016-07-11  7:12       ` Maxime Ripard
  -1 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-11  7:12 UTC (permalink / raw)
  To: u-boot

On Wed, Jul 06, 2016 at 11:22:48AM +1000, David Gibson wrote:
> On Tue, Jul 05, 2016 at 10:26:42AM +0200, Maxime Ripard wrote:
> > Add a function to retrieve a writeable property only by the first
> > characters of its name.
> > 
> > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> 
> This shouldn't be exported, so it should go into libfdt_internal.h.
> 
> > ---
> >  include/libfdt.h | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/include/libfdt.h b/include/libfdt.h
> > index f13b01f08f71..a55d2d0d8c7b 100644
> > --- a/include/libfdt.h
> > +++ b/include/libfdt.h
> > @@ -619,6 +619,13 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
> >   */
> >  const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
> >  				const char *name, int namelen, int *lenp);
> > +static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
> > +					  const char *name, int namelen,
> > +					  int *lenp)
> > +{
> > +	return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
> > +						      namelen, lenp);
> 
> uintptr_t ??

This is defined in the exact same way than fdt_getprop_w. Should I
change that as well?

Thanks,
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160711/966419c9/attachment.sig>

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

* Re: [PATCH v4 09/13] libfdt: Add fdt_getprop_namelen_w
@ 2016-07-11  7:12       ` Maxime Ripard
  0 siblings, 0 replies; 76+ messages in thread
From: Maxime Ripard @ 2016-07-11  7:12 UTC (permalink / raw)
  To: David Gibson
  Cc: Thomas Petazzoni, Tom Rini, u-boot, Pantelis Antoniou,
	Alexander Kaplan, devicetree-compiler


[-- Attachment #1.1: Type: text/plain, Size: 1345 bytes --]

On Wed, Jul 06, 2016 at 11:22:48AM +1000, David Gibson wrote:
> On Tue, Jul 05, 2016 at 10:26:42AM +0200, Maxime Ripard wrote:
> > Add a function to retrieve a writeable property only by the first
> > characters of its name.
> > 
> > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> 
> This shouldn't be exported, so it should go into libfdt_internal.h.
> 
> > ---
> >  include/libfdt.h | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/include/libfdt.h b/include/libfdt.h
> > index f13b01f08f71..a55d2d0d8c7b 100644
> > --- a/include/libfdt.h
> > +++ b/include/libfdt.h
> > @@ -619,6 +619,13 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
> >   */
> >  const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
> >  				const char *name, int namelen, int *lenp);
> > +static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
> > +					  const char *name, int namelen,
> > +					  int *lenp)
> > +{
> > +	return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
> > +						      namelen, lenp);
> 
> uintptr_t ??

This is defined in the exact same way than fdt_getprop_w. Should I
change that as well?

Thanks,
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 134 bytes --]

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

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

* [U-Boot] [PATCH v4 09/13] libfdt: Add fdt_getprop_namelen_w
  2016-07-11  7:12       ` Maxime Ripard
@ 2016-07-12  5:10         ` David Gibson
  -1 siblings, 0 replies; 76+ messages in thread
From: David Gibson @ 2016-07-12  5:10 UTC (permalink / raw)
  To: u-boot

On Mon, Jul 11, 2016 at 09:12:27AM +0200, Maxime Ripard wrote:
> On Wed, Jul 06, 2016 at 11:22:48AM +1000, David Gibson wrote:
> > On Tue, Jul 05, 2016 at 10:26:42AM +0200, Maxime Ripard wrote:
> > > Add a function to retrieve a writeable property only by the first
> > > characters of its name.
> > > 
> > > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > 
> > This shouldn't be exported, so it should go into libfdt_internal.h.
> > 
> > > ---
> > >  include/libfdt.h | 7 +++++++
> > >  1 file changed, 7 insertions(+)
> > > 
> > > diff --git a/include/libfdt.h b/include/libfdt.h
> > > index f13b01f08f71..a55d2d0d8c7b 100644
> > > --- a/include/libfdt.h
> > > +++ b/include/libfdt.h
> > > @@ -619,6 +619,13 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
> > >   */
> > >  const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
> > >  				const char *name, int namelen, int *lenp);
> > > +static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
> > > +					  const char *name, int namelen,
> > > +					  int *lenp)
> > > +{
> > > +	return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
> > > +						      namelen, lenp);
> > 
> > uintptr_t ??
> 
> This is defined in the exact same way than fdt_getprop_w. Should I
> change that as well?

Good point.  I wonder why I did that in the first place.  I suspect it
was to stop sparse whinging about the removed const.  It's ok for now,
we can clean both up later if we get a better idea.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160712/3f00994a/attachment.sig>

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

* Re: [PATCH v4 09/13] libfdt: Add fdt_getprop_namelen_w
@ 2016-07-12  5:10         ` David Gibson
  0 siblings, 0 replies; 76+ messages in thread
From: David Gibson @ 2016-07-12  5:10 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Boris Brezillon,
	Alexander Kaplan, Thomas Petazzoni,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Antoine Ténart,
	Hans de Goede, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Stefan Agner

[-- Attachment #1: Type: text/plain, Size: 1776 bytes --]

On Mon, Jul 11, 2016 at 09:12:27AM +0200, Maxime Ripard wrote:
> On Wed, Jul 06, 2016 at 11:22:48AM +1000, David Gibson wrote:
> > On Tue, Jul 05, 2016 at 10:26:42AM +0200, Maxime Ripard wrote:
> > > Add a function to retrieve a writeable property only by the first
> > > characters of its name.
> > > 
> > > Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> > 
> > This shouldn't be exported, so it should go into libfdt_internal.h.
> > 
> > > ---
> > >  include/libfdt.h | 7 +++++++
> > >  1 file changed, 7 insertions(+)
> > > 
> > > diff --git a/include/libfdt.h b/include/libfdt.h
> > > index f13b01f08f71..a55d2d0d8c7b 100644
> > > --- a/include/libfdt.h
> > > +++ b/include/libfdt.h
> > > @@ -619,6 +619,13 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
> > >   */
> > >  const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
> > >  				const char *name, int namelen, int *lenp);
> > > +static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
> > > +					  const char *name, int namelen,
> > > +					  int *lenp)
> > > +{
> > > +	return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
> > > +						      namelen, lenp);
> > 
> > uintptr_t ??
> 
> This is defined in the exact same way than fdt_getprop_w. Should I
> change that as well?

Good point.  I wonder why I did that in the first place.  I suspect it
was to stop sparse whinging about the removed const.  It's ok for now,
we can clean both up later if we get a better idea.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [U-Boot, v4, 01/13] cmd: fdt: Narrow the check for fdt addr
@ 2016-08-16  1:52     ` Jaehoon Chung
  0 siblings, 0 replies; 76+ messages in thread
From: Jaehoon Chung @ 2016-08-16  1:52 UTC (permalink / raw)
  To: u-boot

Hi,

On 07/05/2016 05:26 PM, Maxime Ripard wrote:
> The current code only checks if the fdt subcommand is fdt addr by checking
> whether it starts with 'a'.
> 
> Since this is a pretty widely used letter, narrow down that check a bit.
> 
> Acked-by: Simon Glass <sjg@chromium.org>
> Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

I don't know what these patchset were delegated to me..I think it's not my scope.
Simon is FDT maintainer..Could you check these patch-set?

Best Regards,
Jaehoon Chung

> ---
>  cmd/fdt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/cmd/fdt.c b/cmd/fdt.c
> index 898217ffe5f8..0f5923e75a41 100644
> --- a/cmd/fdt.c
> +++ b/cmd/fdt.c
> @@ -87,7 +87,7 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  	/*
>  	 * Set the address of the fdt
>  	 */
> -	if (argv[1][0] == 'a') {
> +	if (strncmp(argv[1], "ad", 2) == 0) {
>  		unsigned long addr;
>  		int control = 0;
>  		struct fdt_header *blob;
> 

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

* Re: [U-Boot,v4,01/13] cmd: fdt: Narrow the check for fdt addr
@ 2016-08-16  1:52     ` Jaehoon Chung
  0 siblings, 0 replies; 76+ messages in thread
From: Jaehoon Chung @ 2016-08-16  1:52 UTC (permalink / raw)
  To: Maxime Ripard, Pantelis Antoniou, Simon Glass
  Cc: Thomas Petazzoni, Tom Rini, u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	Alexander Kaplan, devicetree-compiler-u79uwXL29TY76Z2rM5mHXA,
	David Gibson

Hi,

On 07/05/2016 05:26 PM, Maxime Ripard wrote:
> The current code only checks if the fdt subcommand is fdt addr by checking
> whether it starts with 'a'.
> 
> Since this is a pretty widely used letter, narrow down that check a bit.
> 
> Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> Acked-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

I don't know what these patchset were delegated to me..I think it's not my scope.
Simon is FDT maintainer..Could you check these patch-set?

Best Regards,
Jaehoon Chung

> ---
>  cmd/fdt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/cmd/fdt.c b/cmd/fdt.c
> index 898217ffe5f8..0f5923e75a41 100644
> --- a/cmd/fdt.c
> +++ b/cmd/fdt.c
> @@ -87,7 +87,7 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  	/*
>  	 * Set the address of the fdt
>  	 */
> -	if (argv[1][0] == 'a') {
> +	if (strncmp(argv[1], "ad", 2) == 0) {
>  		unsigned long addr;
>  		int control = 0;
>  		struct fdt_header *blob;
> 

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

* [U-Boot] [U-Boot, v4, 01/13] cmd: fdt: Narrow the check for fdt addr
@ 2016-08-16  1:55       ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-16  1:55 UTC (permalink / raw)
  To: u-boot

On Tue, Aug 16, 2016 at 10:52:04AM +0900, Jaehoon Chung wrote:
> Hi,
> 
> On 07/05/2016 05:26 PM, Maxime Ripard wrote:
> > The current code only checks if the fdt subcommand is fdt addr by checking
> > whether it starts with 'a'.
> > 
> > Since this is a pretty widely used letter, narrow down that check a bit.
> > 
> > Acked-by: Simon Glass <sjg@chromium.org>
> > Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> 
> I don't know what these patchset were delegated to me..I think it's not my scope.
> Simon is FDT maintainer..Could you check these patch-set?

Ah whoops, that would be me.  I assigned Pantelis some FDT stuff in
patchwork too, but I bulk changed it all over to you, sorry!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160815/97eb1dde/attachment.sig>

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

* Re: [U-Boot,v4,01/13] cmd: fdt: Narrow the check for fdt addr
@ 2016-08-16  1:55       ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-16  1:55 UTC (permalink / raw)
  To: Jaehoon Chung
  Cc: Maxime Ripard, Pantelis Antoniou, Simon Glass, Thomas Petazzoni,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg, Alexander Kaplan,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson

[-- Attachment #1: Type: text/plain, Size: 887 bytes --]

On Tue, Aug 16, 2016 at 10:52:04AM +0900, Jaehoon Chung wrote:
> Hi,
> 
> On 07/05/2016 05:26 PM, Maxime Ripard wrote:
> > The current code only checks if the fdt subcommand is fdt addr by checking
> > whether it starts with 'a'.
> > 
> > Since this is a pretty widely used letter, narrow down that check a bit.
> > 
> > Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> > Acked-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
> > Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> 
> I don't know what these patchset were delegated to me..I think it's not my scope.
> Simon is FDT maintainer..Could you check these patch-set?

Ah whoops, that would be me.  I assigned Pantelis some FDT stuff in
patchwork too, but I bulk changed it all over to you, sorry!

-- 
Tom

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [U-Boot, v4, 01/13] cmd: fdt: Narrow the check for fdt addr
  2016-08-16  1:55       ` [U-Boot,v4,01/13] " Tom Rini
@ 2016-08-17  2:31         ` Jaehoon Chung
  -1 siblings, 0 replies; 76+ messages in thread
From: Jaehoon Chung @ 2016-08-17  2:31 UTC (permalink / raw)
  To: u-boot

On 08/16/2016 10:55 AM, Tom Rini wrote:
> On Tue, Aug 16, 2016 at 10:52:04AM +0900, Jaehoon Chung wrote:
>> Hi,
>>
>> On 07/05/2016 05:26 PM, Maxime Ripard wrote:
>>> The current code only checks if the fdt subcommand is fdt addr by checking
>>> whether it starts with 'a'.
>>>
>>> Since this is a pretty widely used letter, narrow down that check a bit.
>>>
>>> Acked-by: Simon Glass <sjg@chromium.org>
>>> Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
>>> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
>>
>> I don't know what these patchset were delegated to me..I think it's not my scope.
>> Simon is FDT maintainer..Could you check these patch-set?
> 
> Ah whoops, that would be me.  I assigned Pantelis some FDT stuff in
> patchwork too, but I bulk changed it all over to you, sorry!

Thanks! :)  Then I will delegate to you, is it ok?

Best Regards,
Jaehoon Chung

> 

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

* Re: [U-Boot,v4,01/13] cmd: fdt: Narrow the check for fdt addr
@ 2016-08-17  2:31         ` Jaehoon Chung
  0 siblings, 0 replies; 76+ messages in thread
From: Jaehoon Chung @ 2016-08-17  2:31 UTC (permalink / raw)
  To: Tom Rini
  Cc: Maxime Ripard, Pantelis Antoniou, Simon Glass, Thomas Petazzoni,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg, Alexander Kaplan,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson

On 08/16/2016 10:55 AM, Tom Rini wrote:
> On Tue, Aug 16, 2016 at 10:52:04AM +0900, Jaehoon Chung wrote:
>> Hi,
>>
>> On 07/05/2016 05:26 PM, Maxime Ripard wrote:
>>> The current code only checks if the fdt subcommand is fdt addr by checking
>>> whether it starts with 'a'.
>>>
>>> Since this is a pretty widely used letter, narrow down that check a bit.
>>>
>>> Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
>>> Acked-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
>>> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
>>
>> I don't know what these patchset were delegated to me..I think it's not my scope.
>> Simon is FDT maintainer..Could you check these patch-set?
> 
> Ah whoops, that would be me.  I assigned Pantelis some FDT stuff in
> patchwork too, but I bulk changed it all over to you, sorry!

Thanks! :)  Then I will delegate to you, is it ok?

Best Regards,
Jaehoon Chung

> 

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

* [U-Boot] [U-Boot, v4, 01/13] cmd: fdt: Narrow the check for fdt addr
@ 2016-08-17 12:48           ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-17 12:48 UTC (permalink / raw)
  To: u-boot

On Wed, Aug 17, 2016 at 11:31:18AM +0900, Jaehoon Chung wrote:
> On 08/16/2016 10:55 AM, Tom Rini wrote:
> > On Tue, Aug 16, 2016 at 10:52:04AM +0900, Jaehoon Chung wrote:
> >> Hi,
> >>
> >> On 07/05/2016 05:26 PM, Maxime Ripard wrote:
> >>> The current code only checks if the fdt subcommand is fdt addr by checking
> >>> whether it starts with 'a'.
> >>>
> >>> Since this is a pretty widely used letter, narrow down that check a bit.
> >>>
> >>> Acked-by: Simon Glass <sjg@chromium.org>
> >>> Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> >>> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> >>
> >> I don't know what these patchset were delegated to me..I think it's not my scope.
> >> Simon is FDT maintainer..Could you check these patch-set?
> > 
> > Ah whoops, that would be me.  I assigned Pantelis some FDT stuff in
> > patchwork too, but I bulk changed it all over to you, sorry!
> 
> Thanks! :)  Then I will delegate to you, is it ok?

Sure.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160817/374cbadf/attachment.sig>

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

* Re: [U-Boot,v4,01/13] cmd: fdt: Narrow the check for fdt addr
@ 2016-08-17 12:48           ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-17 12:48 UTC (permalink / raw)
  To: Jaehoon Chung
  Cc: Maxime Ripard, Pantelis Antoniou, Simon Glass, Thomas Petazzoni,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg, Alexander Kaplan,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson

[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]

On Wed, Aug 17, 2016 at 11:31:18AM +0900, Jaehoon Chung wrote:
> On 08/16/2016 10:55 AM, Tom Rini wrote:
> > On Tue, Aug 16, 2016 at 10:52:04AM +0900, Jaehoon Chung wrote:
> >> Hi,
> >>
> >> On 07/05/2016 05:26 PM, Maxime Ripard wrote:
> >>> The current code only checks if the fdt subcommand is fdt addr by checking
> >>> whether it starts with 'a'.
> >>>
> >>> Since this is a pretty widely used letter, narrow down that check a bit.
> >>>
> >>> Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> >>> Acked-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
> >>> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> >>
> >> I don't know what these patchset were delegated to me..I think it's not my scope.
> >> Simon is FDT maintainer..Could you check these patch-set?
> > 
> > Ah whoops, that would be me.  I assigned Pantelis some FDT stuff in
> > patchwork too, but I bulk changed it all over to you, sorry!
> 
> Thanks! :)  Then I will delegate to you, is it ok?

Sure.

-- 
Tom

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [U-Boot, v4, 01/13] cmd: fdt: Narrow the check for fdt addr
@ 2016-08-21 15:06     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:06 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 05, 2016 at 10:26:34AM +0200, Maxime Ripard wrote:

> The current code only checks if the fdt subcommand is fdt addr by checking
> whether it starts with 'a'.
> 
> Since this is a pretty widely used letter, narrow down that check a bit.
> 
> Acked-by: Simon Glass <sjg@chromium.org>
> Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160821/12e5441b/attachment.sig>

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

* Re: [U-Boot,v4,01/13] cmd: fdt: Narrow the check for fdt addr
@ 2016-08-21 15:06     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:06 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Thomas Petazzoni,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg, Alexander Kaplan,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson

[-- Attachment #1: Type: text/plain, Size: 568 bytes --]

On Tue, Jul 05, 2016 at 10:26:34AM +0200, Maxime Ripard wrote:

> The current code only checks if the fdt subcommand is fdt addr by checking
> whether it starts with 'a'.
> 
> Since this is a pretty widely used letter, narrow down that check a bit.
> 
> Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> Acked-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [U-Boot, v4, 02/13] scripts: Makefile.lib: Sanitize DTB names
@ 2016-08-21 15:06     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:06 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 05, 2016 at 10:26:35AM +0200, Maxime Ripard wrote:

> Having dashes as a separator in the DTB name is a quite common practice.
> 
> However, the current code to generate objects from DTBs assumes the
> separator is an underscore, leading to a compilation error when building a
> device tree with dashes.
> 
> Replace all the dashes in the DTB name to generate the symbols name, which
> should solve this issue.
> 
> Acked-by: Simon Glass <sjg@chromium.org>
> Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160821/18b94982/attachment.sig>

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

* Re: [U-Boot,v4,02/13] scripts: Makefile.lib: Sanitize DTB names
@ 2016-08-21 15:06     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:06 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Thomas Petazzoni,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg, Alexander Kaplan,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson

[-- Attachment #1: Type: text/plain, Size: 746 bytes --]

On Tue, Jul 05, 2016 at 10:26:35AM +0200, Maxime Ripard wrote:

> Having dashes as a separator in the DTB name is a quite common practice.
> 
> However, the current code to generate objects from DTBs assumes the
> separator is an underscore, leading to a compilation error when building a
> device tree with dashes.
> 
> Replace all the dashes in the DTB name to generate the symbols name, which
> should solve this issue.
> 
> Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> Acked-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [U-Boot, v4, 03/13] vsprintf: Include stdarg for va_list
@ 2016-08-21 15:06     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:06 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 05, 2016 at 10:26:36AM +0200, Maxime Ripard wrote:

> vsprintf.h doesn't include the stdarg.h file, which means that it relies on
> the files that include vsprintf.h to include stdarg.h as well.
> 
> Add an explicit include to avoid build errors when simply including that
> file.
> 
> Acked-by: Simon Glass <sjg@chromium.org>
> Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160821/668f6fe0/attachment.sig>

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

* Re: [U-Boot,v4,03/13] vsprintf: Include stdarg for va_list
@ 2016-08-21 15:06     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:06 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Thomas Petazzoni,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg, Alexander Kaplan,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson

[-- Attachment #1: Type: text/plain, Size: 613 bytes --]

On Tue, Jul 05, 2016 at 10:26:36AM +0200, Maxime Ripard wrote:

> vsprintf.h doesn't include the stdarg.h file, which means that it relies on
> the files that include vsprintf.h to include stdarg.h as well.
> 
> Add an explicit include to avoid build errors when simply including that
> file.
> 
> Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> Acked-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [U-Boot,v4,04/13] libfdt: Add new headers and defines
@ 2016-08-21 15:07     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:07 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 05, 2016 at 10:26:37AM +0200, Maxime Ripard wrote:

> The libfdt overlay support introduces a bunch of new includes and
> functions.
> 
> Make sure we are able to build it by adding the needed glue.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160821/e543a67f/attachment.sig>

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

* Re: [U-Boot,v4,04/13] libfdt: Add new headers and defines
@ 2016-08-21 15:07     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:07 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Thomas Petazzoni,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg, Alexander Kaplan,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson

[-- Attachment #1: Type: text/plain, Size: 439 bytes --]

On Tue, Jul 05, 2016 at 10:26:37AM +0200, Maxime Ripard wrote:

> The libfdt overlay support introduces a bunch of new includes and
> functions.
> 
> Make sure we are able to build it by adding the needed glue.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [U-Boot, v4, 05/13] libfdt: Add iterator over properties
@ 2016-08-21 15:07     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:07 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 05, 2016 at 10:26:38AM +0200, Maxime Ripard wrote:

> Implement a macro based on fdt_first_property_offset and
> fdt_next_property_offset that provides a convenience to iterate over all
> the properties of a given node.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160821/91ae2e33/attachment.sig>

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

* Re: [U-Boot,v4,05/13] libfdt: Add iterator over properties
@ 2016-08-21 15:07     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:07 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Thomas Petazzoni,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg, Alexander Kaplan,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson

[-- Attachment #1: Type: text/plain, Size: 459 bytes --]

On Tue, Jul 05, 2016 at 10:26:38AM +0200, Maxime Ripard wrote:

> Implement a macro based on fdt_first_property_offset and
> fdt_next_property_offset that provides a convenience to iterate over all
> the properties of a given node.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [U-Boot, v4, 06/13] libfdt: Add max phandle retrieval function
@ 2016-08-21 15:07     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:07 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 05, 2016 at 10:26:39AM +0200, Maxime Ripard wrote:

> Add a function to retrieve the highest phandle in a given device tree.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> Reviewed-by: Stefan Agner <stefan@agner.ch>
> Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160821/1bd808f0/attachment.sig>

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

* Re: [U-Boot,v4,06/13] libfdt: Add max phandle retrieval function
@ 2016-08-21 15:07     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:07 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Thomas Petazzoni,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg, Alexander Kaplan,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson

[-- Attachment #1: Type: text/plain, Size: 429 bytes --]

On Tue, Jul 05, 2016 at 10:26:39AM +0200, Maxime Ripard wrote:

> Add a function to retrieve the highest phandle in a given device tree.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> Reviewed-by: Stefan Agner <stefan-XLVq0VzYD2Y@public.gmane.org>
> Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [U-Boot,v4,07/13] libfdt: Fix separator spelling
@ 2016-08-21 15:07     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:07 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 05, 2016 at 10:26:40AM +0200, Maxime Ripard wrote:

> The function fdt_path_next_seperator had an obvious mispell. Fix it.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160821/ce380ae0/attachment.sig>

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

* Re: [U-Boot,v4,07/13] libfdt: Fix separator spelling
@ 2016-08-21 15:07     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:07 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Thomas Petazzoni,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg, Alexander Kaplan,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson

[-- Attachment #1: Type: text/plain, Size: 289 bytes --]

On Tue, Jul 05, 2016 at 10:26:40AM +0200, Maxime Ripard wrote:

> The function fdt_path_next_seperator had an obvious mispell. Fix it.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [U-Boot,v4,08/13] libfdt: Add fdt_path_offset_namelen
@ 2016-08-21 15:07     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:07 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 05, 2016 at 10:26:41AM +0200, Maxime Ripard wrote:

> Add a namelen variant of fdt_path_offset to retrieve the node offset using
> only a fixed number of characters.
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160821/8d5043c4/attachment.sig>

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

* Re: [U-Boot,v4,08/13] libfdt: Add fdt_path_offset_namelen
@ 2016-08-21 15:07     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:07 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Thomas Petazzoni,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg, Alexander Kaplan,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

On Tue, Jul 05, 2016 at 10:26:41AM +0200, Maxime Ripard wrote:

> Add a namelen variant of fdt_path_offset to retrieve the node offset using
> only a fixed number of characters.
> 
> Reviewed-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [U-Boot,v4,09/13] libfdt: Add fdt_getprop_namelen_w
@ 2016-08-21 15:07     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:07 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 05, 2016 at 10:26:42AM +0200, Maxime Ripard wrote:

> Add a function to retrieve a writeable property only by the first
> characters of its name.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160821/de6fc3ce/attachment.sig>

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

* Re: [U-Boot,v4,09/13] libfdt: Add fdt_getprop_namelen_w
@ 2016-08-21 15:07     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:07 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Thomas Petazzoni,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg, Alexander Kaplan,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson

[-- Attachment #1: Type: text/plain, Size: 313 bytes --]

On Tue, Jul 05, 2016 at 10:26:42AM +0200, Maxime Ripard wrote:

> Add a function to retrieve a writeable property only by the first
> characters of its name.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [U-Boot, v4, 10/13] libfdt: Add fdt_setprop_inplace_namelen_partial
@ 2016-08-21 15:07     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:07 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 05, 2016 at 10:26:43AM +0200, Maxime Ripard wrote:

> Add a function to modify inplace only a portion of a property..
> 
> This is especially useful when the property is an array of values, and you
> want to update one of them without changing the DT size.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160821/1f55f472/attachment.sig>

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

* Re: [U-Boot,v4,10/13] libfdt: Add fdt_setprop_inplace_namelen_partial
@ 2016-08-21 15:07     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:07 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Thomas Petazzoni,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg, Alexander Kaplan,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson

[-- Attachment #1: Type: text/plain, Size: 497 bytes --]

On Tue, Jul 05, 2016 at 10:26:43AM +0200, Maxime Ripard wrote:

> Add a function to modify inplace only a portion of a property..
> 
> This is especially useful when the property is an array of values, and you
> want to update one of them without changing the DT size.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [U-Boot, v4, 11/13] libfdt: Add overlay application function
@ 2016-08-21 15:07     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:07 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 05, 2016 at 10:26:44AM +0200, Maxime Ripard wrote:

> The device tree overlays are a good way to deal with user-modifyable
> boards or boards with some kind of an expansion mechanism where we can
> easily plug new board in (like the BBB, the Raspberry Pi or the CHIP).
> 
> Add a new function to merge overlays with a base device tree.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160821/0e1ce308/attachment.sig>

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

* Re: [U-Boot,v4,11/13] libfdt: Add overlay application function
@ 2016-08-21 15:07     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:07 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Thomas Petazzoni,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg, Alexander Kaplan,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson

[-- Attachment #1: Type: text/plain, Size: 506 bytes --]

On Tue, Jul 05, 2016 at 10:26:44AM +0200, Maxime Ripard wrote:

> The device tree overlays are a good way to deal with user-modifyable
> boards or boards with some kind of an expansion mechanism where we can
> easily plug new board in (like the BBB, the Raspberry Pi or the CHIP).
> 
> Add a new function to merge overlays with a base device tree.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [U-Boot, v4, 12/13] cmd: fdt: add fdt overlay application subcommand
@ 2016-08-21 15:08     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:08 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 05, 2016 at 10:26:45AM +0200, Maxime Ripard wrote:

> The device tree overlays are a good way to deal with user-modifyable
> boards or boards with some kind of an expansion mechanism where we can
> easily plug new board in (like the BBB or the raspberry pi).
> 
> However, so far, the usual mechanism to deal with it was to have in Linux
> some driver detecting the expansion boards plugged in and then request
> these overlays using the firmware interface.
> 
> That works in most cases, but in some cases, you might want to have the
> overlays applied before the userspace comes in. Either because the new
> board requires some kind of an early initialization, or because your root
> filesystem is accessed through that expansion board.
> 
> The easiest solution in such a case is to simply have the component before
> Linux applying that overlay, removing all these drawbacks.
> 
> Reviewed-by: Stefan Agner <stefan@agner.ch>
> Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> Acked-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160821/d2a886e4/attachment.sig>

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

* Re: [U-Boot,v4,12/13] cmd: fdt: add fdt overlay application subcommand
@ 2016-08-21 15:08     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:08 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Thomas Petazzoni,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg, Alexander Kaplan,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson

[-- Attachment #1: Type: text/plain, Size: 1289 bytes --]

On Tue, Jul 05, 2016 at 10:26:45AM +0200, Maxime Ripard wrote:

> The device tree overlays are a good way to deal with user-modifyable
> boards or boards with some kind of an expansion mechanism where we can
> easily plug new board in (like the BBB or the raspberry pi).
> 
> However, so far, the usual mechanism to deal with it was to have in Linux
> some driver detecting the expansion boards plugged in and then request
> these overlays using the firmware interface.
> 
> That works in most cases, but in some cases, you might want to have the
> overlays applied before the userspace comes in. Either because the new
> board requires some kind of an early initialization, or because your root
> filesystem is accessed through that expansion board.
> 
> The easiest solution in such a case is to simply have the component before
> Linux applying that overlay, removing all these drawbacks.
> 
> Reviewed-by: Stefan Agner <stefan-XLVq0VzYD2Y@public.gmane.org>
> Acked-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
> Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [U-Boot] [U-Boot,v4,13/13] tests: Introduce DT overlay tests
@ 2016-08-21 15:08     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:08 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 05, 2016 at 10:26:46AM +0200, Maxime Ripard wrote:

> This adds a bunch of unit tests for the "fdt apply" command.
> 
> They've all been run successfully in the sandbox. However, as you still
> require an out-of-tree dtc with overlay support, this is disabled by
> default.
> 
> Acked-by: Simon Glass <sjg@chromium.org>
> Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160821/f71dc3db/attachment.sig>

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

* Re: [U-Boot,v4,13/13] tests: Introduce DT overlay tests
@ 2016-08-21 15:08     ` Tom Rini
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Rini @ 2016-08-21 15:08 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Pantelis Antoniou, Simon Glass, Thomas Petazzoni,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg, Alexander Kaplan,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson

[-- Attachment #1: Type: text/plain, Size: 606 bytes --]

On Tue, Jul 05, 2016 at 10:26:46AM +0200, Maxime Ripard wrote:

> This adds a bunch of unit tests for the "fdt apply" command.
> 
> They've all been run successfully in the sandbox. However, as you still
> require an out-of-tree dtc with overlay support, this is disabled by
> default.
> 
> Acked-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> Acked-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2016-08-21 15:08 UTC | newest]

Thread overview: 76+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-05  8:26 [U-Boot] [PATCH v4 00/13] cmd: fdt: Add device tree overlays support Maxime Ripard
2016-07-05  8:26 ` Maxime Ripard
2016-07-05  8:26 ` [U-Boot] [PATCH v4 01/13] cmd: fdt: Narrow the check for fdt addr Maxime Ripard
2016-07-05  8:26   ` Maxime Ripard
2016-08-16  1:52   ` [U-Boot] [U-Boot, v4, " Jaehoon Chung
2016-08-16  1:52     ` [U-Boot,v4,01/13] " Jaehoon Chung
2016-08-16  1:55     ` [U-Boot] [U-Boot, v4, 01/13] " Tom Rini
2016-08-16  1:55       ` [U-Boot,v4,01/13] " Tom Rini
2016-08-17  2:31       ` [U-Boot] [U-Boot, v4, 01/13] " Jaehoon Chung
2016-08-17  2:31         ` [U-Boot,v4,01/13] " Jaehoon Chung
2016-08-17 12:48         ` [U-Boot] [U-Boot, v4, 01/13] " Tom Rini
2016-08-17 12:48           ` [U-Boot,v4,01/13] " Tom Rini
2016-08-21 15:06   ` [U-Boot] [U-Boot, v4, 01/13] " Tom Rini
2016-08-21 15:06     ` [U-Boot,v4,01/13] " Tom Rini
2016-07-05  8:26 ` [U-Boot] [PATCH v4 02/13] scripts: Makefile.lib: Sanitize DTB names Maxime Ripard
2016-07-05  8:26   ` Maxime Ripard
2016-08-21 15:06   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-08-21 15:06     ` [U-Boot,v4,02/13] " Tom Rini
2016-07-05  8:26 ` [U-Boot] [PATCH v4 03/13] vsprintf: Include stdarg for va_list Maxime Ripard
2016-07-05  8:26   ` Maxime Ripard
2016-08-21 15:06   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-08-21 15:06     ` [U-Boot,v4,03/13] " Tom Rini
2016-07-05  8:26 ` [U-Boot] [PATCH v4 04/13] libfdt: Add new headers and defines Maxime Ripard
2016-07-05  8:26   ` Maxime Ripard
2016-08-21 15:07   ` [U-Boot] [U-Boot,v4,04/13] " Tom Rini
2016-08-21 15:07     ` Tom Rini
2016-07-05  8:26 ` [U-Boot] [PATCH v4 05/13] libfdt: Add iterator over properties Maxime Ripard
2016-07-05  8:26   ` Maxime Ripard
2016-08-21 15:07   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-08-21 15:07     ` [U-Boot,v4,05/13] " Tom Rini
2016-07-05  8:26 ` [U-Boot] [PATCH v4 06/13] libfdt: Add max phandle retrieval function Maxime Ripard
2016-07-05  8:26   ` Maxime Ripard
2016-07-06  1:13   ` [U-Boot] " David Gibson
2016-07-06  1:13     ` David Gibson
2016-08-21 15:07   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-08-21 15:07     ` [U-Boot,v4,06/13] " Tom Rini
2016-07-05  8:26 ` [U-Boot] [PATCH v4 07/13] libfdt: Fix separator spelling Maxime Ripard
2016-07-05  8:26   ` Maxime Ripard
2016-07-06  1:16   ` [U-Boot] " David Gibson
2016-07-06  1:16     ` David Gibson
2016-07-11  6:59     ` [U-Boot] " Maxime Ripard
2016-07-11  6:59       ` Maxime Ripard
2016-08-21 15:07   ` [U-Boot] [U-Boot,v4,07/13] " Tom Rini
2016-08-21 15:07     ` Tom Rini
2016-07-05  8:26 ` [U-Boot] [PATCH v4 08/13] libfdt: Add fdt_path_offset_namelen Maxime Ripard
2016-07-05  8:26   ` Maxime Ripard
2016-07-06  1:21   ` [U-Boot] " David Gibson
2016-07-06  1:21     ` David Gibson
2016-08-21 15:07   ` [U-Boot] [U-Boot,v4,08/13] " Tom Rini
2016-08-21 15:07     ` Tom Rini
2016-07-05  8:26 ` [U-Boot] [PATCH v4 09/13] libfdt: Add fdt_getprop_namelen_w Maxime Ripard
2016-07-05  8:26   ` Maxime Ripard
2016-07-06  1:22   ` [U-Boot] " David Gibson
2016-07-06  1:22     ` David Gibson
2016-07-11  7:12     ` [U-Boot] " Maxime Ripard
2016-07-11  7:12       ` Maxime Ripard
2016-07-12  5:10       ` [U-Boot] " David Gibson
2016-07-12  5:10         ` David Gibson
2016-08-21 15:07   ` [U-Boot] [U-Boot,v4,09/13] " Tom Rini
2016-08-21 15:07     ` Tom Rini
2016-07-05  8:26 ` [U-Boot] [PATCH v4 10/13] libfdt: Add fdt_setprop_inplace_namelen_partial Maxime Ripard
2016-07-05  8:26   ` Maxime Ripard
2016-08-21 15:07   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-08-21 15:07     ` [U-Boot,v4,10/13] " Tom Rini
2016-07-05  8:26 ` [U-Boot] [PATCH v4 11/13] libfdt: Add overlay application function Maxime Ripard
2016-07-05  8:26   ` Maxime Ripard
2016-08-21 15:07   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-08-21 15:07     ` [U-Boot,v4,11/13] " Tom Rini
2016-07-05  8:26 ` [U-Boot] [PATCH v4 12/13] cmd: fdt: add fdt overlay application subcommand Maxime Ripard
2016-07-05  8:26   ` Maxime Ripard
2016-08-21 15:08   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-08-21 15:08     ` [U-Boot,v4,12/13] " Tom Rini
2016-07-05  8:26 ` [U-Boot] [PATCH v4 13/13] tests: Introduce DT overlay tests Maxime Ripard
2016-07-05  8:26   ` Maxime Ripard
2016-08-21 15:08   ` [U-Boot] [U-Boot,v4,13/13] " Tom Rini
2016-08-21 15:08     ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.