On 06/01/2020 15:19, David Gibson wrote:
+ const struct fdt_property *prop;
+ const char *tmp;
+
+ readstr(prevaddr, prev);
+ for (offset = fdt_first_property_offset(fdt, offset);
+ (offset >= 0);
+ (offset = fdt_next_property_offset(fdt, offset))) {
+
+ prop = fdt_get_property_by_offset(fdt, offset, &namelen);
fdt_getprop_by_offset() also returns the property's name without
having to dick around with fdt_get_string() manually.
btw I looked quickly:
const void *fdt_getprop_by_offset(const void *fdt, int offset,
const char **namep, int *lenp)
{
const struct fdt_property *prop;
prop = fdt_get_property_by_offset_(fdt, offset, lenp);
if (!prop)
return NULL;
if (namep) {
const char *name;
int namelen;
name = fdt_get_string(fdt, fdt32_ld(&prop->nameoff),
&namelen);
if (!name) {
if (lenp)
*lenp = namelen;
return NULL;
}
*namep = name;
}
/* Handle realignment */
if (fdt_version(fdt) < 0x10 && (offset + sizeof(*prop)) % 8 &&
fdt32_ld(&prop->len) >= 8)
return prop->data + 4;
return prop->data;
}
and incorrectly assumed *lenp is the name length because of "*lenp = namelen".
Huh :)
--
Alexey