int lists_bind_fdt(struct udevice *parent, const void *blob, int offset, struct udevice **devp) { struct driver *driver = ll_entry_start(struct driver, driver); const int n_ents = ll_entry_count(struct driver, driver); const struct udevice_id *id; struct driver *entry; struct udevice *dev; bool found = false; const char *name; int result = 0; int ret = 0; dm_dbg("bind node %s\n", fdt_get_name(blob, offset, NULL)); if (devp) *devp = NULL; for (entry = driver; entry != driver + n_ents; entry++) { ret = driver_check_compatible(blob, offset, entry->of_match, &id); name = fdt_get_name(blob, offset, NULL); if (ret == -ENOENT) { continue; } else if (ret == -ENODEV) { dm_dbg("Device '%s' has no compatible string\n", name); break; } else if (ret) { dm_warn("Device tree error at offset %d\n", offset); result = ret; break; } dm_dbg(" - found match at '%s'\n", entry->name); ret = device_bind_with_driver_data(parent, entry, name, id->data, offset, &dev); if (ret == -ENODEV) { dm_dbg("Driver '%s' refuses to bind\n", entry->name); continue; } if (ret) { dm_warn("Error binding driver '%s': %d\n", entry->name, ret); return ret; } else { found = true; if (devp) *devp = dev; } break; } if (!found && !result && ret != -ENODEV) { dm_dbg("No match for node '%s'\n", fdt_get_name(blob, offset, NULL)); } return result; }
int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset, bool pre_reloc_only) { int ret = 0, err; for (offset = fdt_first_subnode(blob, offset); offset > 0; offset = fdt_next_subnode(blob, offset)) { if (pre_reloc_only && !fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL)) continue; if (!fdtdec_get_is_enabled(blob, offset)) { dm_dbg(" - ignoring disabled device\n"); continue; } err = lists_bind_fdt(parent, blob, offset, NULL); if (err && !ret) { ret = err; debug("%s: ret=%d\n", fdt_get_name(blob, offset, NULL), ret); } } if (ret) dm_warn("Some drivers failed to bind\n"); return ret; }
int lists_bind_fdt(struct udevice *parent, const void *blob, int offset) { struct driver *driver = ll_entry_start(struct driver, driver); const int n_ents = ll_entry_count(struct driver, driver); struct driver *entry; struct udevice *dev; const char *name; int result = 0; int ret; dm_dbg("bind node %s\n", fdt_get_name(blob, offset, NULL)); for (entry = driver; entry != driver + n_ents; entry++) { ret = driver_check_compatible(blob, offset, entry->of_match); if (ret == -ENOENT) { continue; } else if (ret == -ENODEV) { break; } else if (ret) { dm_warn("Device tree error at offset %d\n", offset); if (!result || ret != -ENOENT) result = ret; break; } name = fdt_get_name(blob, offset, NULL); dm_dbg(" - found match at '%s'\n", entry->name); ret = device_bind(parent, entry, name, NULL, offset, &dev); if (ret) { dm_warn("No match for driver '%s'\n", entry->name); if (!result || ret != -ENOENT) result = ret; } } return result; }