debug(" %.2x", *(u8*)(val+i));
debug("\n");
#endif
- off = fdt_node_offset_by_compatible(fdt, -1, compat);
- while (off != -FDT_ERR_NOTFOUND) {
+ fdt_for_each_node_by_compatible(off, fdt, -1, compat)
if (create || (fdt_get_property(fdt, off, prop, NULL) != NULL))
fdt_setprop(fdt, off, prop, val, len);
- off = fdt_node_offset_by_compatible(fdt, off, compat);
- }
}
void do_fixup_by_compat_u32(void *fdt, const char *compat,
{
struct mtd_device *dev;
int i, idx;
- int noff;
+ int noff, parts;
bool inited = false;
for (i = 0; i < node_info_size; i++) {
idx = 0;
- noff = -1;
- while ((noff = fdt_node_offset_by_compatible(blob, noff,
- node_info[i].compat)) >= 0) {
+ fdt_for_each_node_by_compatible(noff, blob, -1,
+ node_info[i].compat) {
const char *prop;
prop = fdt_getprop(blob, noff, "status", NULL);
dev = device_find(node_info[i].type, idx++);
if (dev) {
- if (fdt_node_set_part_info(blob, noff, dev))
+ parts = fdt_subnode_offset(blob, noff,
+ "partitions");
+ if (parts < 0)
+ parts = noff;
+
+ if (fdt_node_set_part_info(blob, parts, dev))
return; /* return on error */
}
}
int fdt_node_offset_by_compat_reg(void *blob, const char *compat,
phys_addr_t compat_off)
{
- int len, off = fdt_node_offset_by_compatible(blob, -1, compat);
- while (off != -FDT_ERR_NOTFOUND) {
+ int len, off;
+
+ fdt_for_each_node_by_compatible(off, blob, -1, compat) {
const fdt32_t *reg = fdt_getprop(blob, off, "reg", &len);
- if (reg) {
- if (compat_off == fdt_translate_address(blob, off, reg))
- return off;
- }
- off = fdt_node_offset_by_compatible(blob, off, compat);
+ if (reg && compat_off == fdt_translate_address(blob, off, reg))
+ return off;
}
return -FDT_ERR_NOTFOUND;
* fdt_valid() - Check if an FDT is valid. If not, change it to NULL
*
* @blobp: Pointer to FDT pointer
- * @return 1 if OK, 0 if bad (in which case *blobp is set to NULL)
+ * Return: 1 if OK, 0 if bad (in which case *blobp is set to NULL)
*/
int fdt_valid(struct fdt_header **blobp)
{