Browse Source

libfdt: Use correct property format

Since its beginning, libfdt has used an incorrect definition of the
format for a property, putting the name offset before length, rather
than the other way around as described in booting-without-of.txt.

This corrects the error, making libfdt actually produce and use trees
which are compatible with the kernel and dtc.

Signed-of-by: David Gibson <david@gibson.dropbear.id.au>
main
David Gibson 18 years ago
parent
commit
07a12a0800
  1. 2
      fdt.c
  2. 2
      fdt.h
  3. 4
      tests/trees.S

2
fdt.c

@ -83,7 +83,7 @@ uint32_t _fdt_next_tag(const void *fdt, int offset, int *nextoffset)
return FDT_END; return FDT_END;
break; break;
case FDT_PROP: case FDT_PROP:
lenp = fdt_offset_ptr(fdt, offset + FDT_TAGSIZE, sizeof(*lenp)); lenp = fdt_offset_ptr(fdt, offset, sizeof(*lenp));
if (! lenp) if (! lenp)
return FDT_END; return FDT_END;
/* skip name offset, length and value */ /* skip name offset, length and value */

2
fdt.h

@ -36,8 +36,8 @@ struct fdt_node_header {


struct fdt_property { struct fdt_property {
uint32_t tag; uint32_t tag;
uint32_t nameoff;
uint32_t len; uint32_t len;
uint32_t nameoff;
char data[0]; char data[0];
}; };



4
tests/trees.S

@ -39,8 +39,8 @@ tree: \


#define PROPHDR(tree, name, len) \ #define PROPHDR(tree, name, len) \
FDTLONG(FDT_PROP) ; \ FDTLONG(FDT_PROP) ; \
FDTLONG(tree##_##name - tree##_strings) ; \ FDTLONG(len) ; \
FDTLONG(len) ; FDTLONG(tree##_##name - tree##_strings) ;


#define PROP_INT(tree, name, val) \ #define PROP_INT(tree, name, val) \
PROPHDR(tree, name, 4) \ PROPHDR(tree, name, 4) \

Loading…
Cancel
Save