diff mbox

[U-Boot,V3,1/4] fdtdec: fix parsing 'reg' property with zero value in '#size-cells'

Message ID 1443611693-23722-2-git-send-email-p.marczak@samsung.com
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Przemyslaw Marczak Sept. 30, 2015, 11:14 a.m. UTC
After rework of lib/fdtdec.c by:

commit: 02464e3 fdt: add new fdt address parsing functions

the function fdtdec_get_addr() doesn't work as previous,
because the implementation assumes that properties '#address-cells'
and '#size-cells' are equal to 1, which can be not true sometimes.

The new API introduced fdtdec_get_addr_size_auto_parent() for the 'reg'
property parsing, but the implementation assumes, that #size-cells
can't be less than 1.

This causes that the following children's 'reg' property can't be reached:

parent@0x0 {
     #address-cells = <1>;
     #size-cells = <0>;
     children@0x100 {
         reg = < 0x100 >;
     };
};

Change the condition value from '1' to '0', which allows parsing property
with at least zero #size-cells, fixes the issue.

Now, fdtdec_get_addr_size_auto_parent() works properly.

Tested on: Odroid U3/X2, Trats, Trats2, Odroid XU3, Snow (by Simon).

Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
---
Changes V2:
- cleanup commit message
- add acked-by
Changes V3:
- add acked-by and tested-by Simon
---
 lib/fdtdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Glass Oct. 3, 2015, 2:28 p.m. UTC | #1
On 30 September 2015 at 12:14, Przemyslaw Marczak <p.marczak@samsung.com> wrote:
> After rework of lib/fdtdec.c by:
>
> commit: 02464e3 fdt: add new fdt address parsing functions
>
> the function fdtdec_get_addr() doesn't work as previous,
> because the implementation assumes that properties '#address-cells'
> and '#size-cells' are equal to 1, which can be not true sometimes.
>
> The new API introduced fdtdec_get_addr_size_auto_parent() for the 'reg'
> property parsing, but the implementation assumes, that #size-cells
> can't be less than 1.
>
> This causes that the following children's 'reg' property can't be reached:
>
> parent@0x0 {
>      #address-cells = <1>;
>      #size-cells = <0>;
>      children@0x100 {
>          reg = < 0x100 >;
>      };
> };
>
> Change the condition value from '1' to '0', which allows parsing property
> with at least zero #size-cells, fixes the issue.
>
> Now, fdtdec_get_addr_size_auto_parent() works properly.
>
> Tested on: Odroid U3/X2, Trats, Trats2, Odroid XU3, Snow (by Simon).
>
> Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
> Acked-by: Stephen Warren <swarren@nvidia.com>
> Acked-by: Simon Glass <sjg@chromium.org>
> Tested-by: Simon Glass <sjg@chromium.org>
> ---
> Changes V2:
> - cleanup commit message
> - add acked-by
> Changes V3:
> - add acked-by and tested-by Simon
> ---
>  lib/fdtdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-fdt, thanks!
diff mbox

Patch

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 9f0b65d..9cf57b9 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -149,7 +149,7 @@  fdt_addr_t fdtdec_get_addr_size_auto_parent(const void *blob, int parent,
 	}
 
 	ns = fdt_size_cells(blob, parent);
-	if (ns < 1) {
+	if (ns < 0) {
 		debug("(bad #size-cells)\n");
 		return FDT_ADDR_T_NONE;
 	}