diff options
author | Bin Meng <bmeng.cn@gmail.com> | 2018-10-10 22:06:58 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2018-11-14 09:16:27 -0800 |
commit | 8d773c4ab3f77a5a6ceed974d00083a312454660 (patch) | |
tree | 4b5411d76a591071a8f210833b6832ac03a18176 /drivers/core | |
parent | e601ab1bb69901420ba2c55d2f2d194a38739182 (diff) | |
download | u-boot-8d773c4ab3f77a5a6ceed974d00083a312454660.zip u-boot-8d773c4ab3f77a5a6ceed974d00083a312454660.tar.gz u-boot-8d773c4ab3f77a5a6ceed974d00083a312454660.tar.bz2 |
dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in lists_bind_fdt()
Currently the comments of several APIs (eg: dm_init_and_scan()) say:
@pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
flag. If false bind all drivers.
The 'Pre-Relocation Support' chapter in doc/driver-model/README.txt
documents the same that both device tree properties and driver flag
are supported.
However the implementation only checks these special device tree
properties without checking the driver flag at all. This updates
lists_bind_fdt() to consider both scenarios.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Squashed in http://patchwork.ozlabs.org/patch/996473/ :
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core')
-rw-r--r-- | drivers/core/device.c | 2 | ||||
-rw-r--r-- | drivers/core/lists.c | 9 | ||||
-rw-r--r-- | drivers/core/root.c | 12 |
3 files changed, 13 insertions, 10 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c index 5176aa3..47a697f 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -834,5 +834,5 @@ int dev_enable_by_path(const char *path) if (ret) return ret; - return lists_bind_fdt(parent, node, NULL); + return lists_bind_fdt(parent, node, NULL, false); } diff --git a/drivers/core/lists.c b/drivers/core/lists.c index a167726..a1f8284 100644 --- a/drivers/core/lists.c +++ b/drivers/core/lists.c @@ -122,7 +122,8 @@ static int driver_check_compatible(const struct udevice_id *of_match, return -ENOENT; } -int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp) +int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp, + bool pre_reloc_only) { struct driver *driver = ll_entry_start(struct driver, driver); const int n_ents = ll_entry_count(struct driver, driver); @@ -171,6 +172,12 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp) if (entry == driver + n_ents) continue; + if (pre_reloc_only) { + if (!dm_ofnode_pre_reloc(node) && + !(entry->flags & DM_FLAG_PRE_RELOC)) + return 0; + } + pr_debug(" - found match at '%s'\n", entry->name); ret = device_bind_with_driver_data(parent, entry, name, id->data, node, &dev); diff --git a/drivers/core/root.c b/drivers/core/root.c index b54bf5b..cd6a5a0 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -222,14 +222,12 @@ static int dm_scan_fdt_live(struct udevice *parent, int ret = 0, err; for (np = node_parent->child; np; np = np->sibling) { - if (pre_reloc_only && - !of_find_property(np, "u-boot,dm-pre-reloc", NULL)) - continue; if (!of_device_is_available(np)) { pr_debug(" - ignoring disabled device\n"); continue; } - err = lists_bind_fdt(parent, np_to_ofnode(np), NULL); + err = lists_bind_fdt(parent, np_to_ofnode(np), NULL, + pre_reloc_only); if (err && !ret) { ret = err; debug("%s: ret=%d\n", np->name, ret); @@ -282,14 +280,12 @@ static int dm_scan_fdt_node(struct udevice *parent, const void *blob, continue; } - if (pre_reloc_only && - !dm_fdt_pre_reloc(blob, offset)) - continue; if (!fdtdec_get_is_enabled(blob, offset)) { pr_debug(" - ignoring disabled device\n"); continue; } - err = lists_bind_fdt(parent, offset_to_ofnode(offset), NULL); + err = lists_bind_fdt(parent, offset_to_ofnode(offset), NULL, + pre_reloc_only); if (err && !ret) { ret = err; debug("%s: ret=%d\n", node_name, ret); |