mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-19 05:31:32 +00:00
dm: Adjust lists_bind_fdt() to return the bound device
Allow the caller to find out the device that was bound in response to this call. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
aac07d49d0
commit
1f359e3611
3 changed files with 13 additions and 5 deletions
|
@ -118,7 +118,8 @@ static int driver_check_compatible(const void *blob, int offset,
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lists_bind_fdt(struct udevice *parent, const void *blob, int offset)
|
int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
|
||||||
|
struct udevice **devp)
|
||||||
{
|
{
|
||||||
struct driver *driver = ll_entry_start(struct driver, driver);
|
struct driver *driver = ll_entry_start(struct driver, driver);
|
||||||
const int n_ents = ll_entry_count(struct driver, driver);
|
const int n_ents = ll_entry_count(struct driver, driver);
|
||||||
|
@ -130,6 +131,8 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset)
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
dm_dbg("bind node %s\n", fdt_get_name(blob, offset, NULL));
|
dm_dbg("bind node %s\n", fdt_get_name(blob, offset, NULL));
|
||||||
|
if (devp)
|
||||||
|
*devp = NULL;
|
||||||
for (entry = driver; entry != driver + n_ents; entry++) {
|
for (entry = driver; entry != driver + n_ents; entry++) {
|
||||||
ret = driver_check_compatible(blob, offset, entry->of_match);
|
ret = driver_check_compatible(blob, offset, entry->of_match);
|
||||||
name = fdt_get_name(blob, offset, NULL);
|
name = fdt_get_name(blob, offset, NULL);
|
||||||
|
@ -149,10 +152,11 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset)
|
||||||
ret = device_bind(parent, entry, name, NULL, offset, &dev);
|
ret = device_bind(parent, entry, name, NULL, offset, &dev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dm_warn("Error binding driver '%s'\n", entry->name);
|
dm_warn("Error binding driver '%s'\n", entry->name);
|
||||||
if (!result || ret != -ENOENT)
|
return ret;
|
||||||
result = ret;
|
|
||||||
} else {
|
} else {
|
||||||
found = true;
|
found = true;
|
||||||
|
if (devp)
|
||||||
|
*devp = dev;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset,
|
||||||
if (pre_reloc_only &&
|
if (pre_reloc_only &&
|
||||||
!fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
|
!fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
|
||||||
continue;
|
continue;
|
||||||
err = lists_bind_fdt(parent, blob, offset);
|
err = lists_bind_fdt(parent, blob, offset, NULL);
|
||||||
if (err && !ret)
|
if (err && !ret)
|
||||||
ret = err;
|
ret = err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,11 @@ int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only);
|
||||||
* @parent: parent driver (root)
|
* @parent: parent driver (root)
|
||||||
* @blob: device tree blob
|
* @blob: device tree blob
|
||||||
* @offset: offset of this device tree node
|
* @offset: offset of this device tree node
|
||||||
|
* @devp: if non-NULL, returns a pointer to the bound device
|
||||||
|
* @return 0 if device was bound, -EINVAL if the device tree is invalid,
|
||||||
|
* other -ve value on error
|
||||||
*/
|
*/
|
||||||
int lists_bind_fdt(struct udevice *parent, const void *blob, int offset);
|
int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
|
||||||
|
struct udevice **devp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue