diff options
author | Jean-Jacques Hiblot <jjhiblot@ti.com> | 2018-08-09 16:17:44 +0200 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2018-08-21 16:21:37 +0200 |
commit | 7ec9181d6a2b68480a289c36e5729487f2a4add1 (patch) | |
tree | a265db6ad852b08e4605bff1df3680d8621b0fd5 /drivers/core/device.c | |
parent | 999b204383ffb4eee1467604a935ed3a670c460e (diff) |
dm: convert device_get_global_by_of_offset() to device_get_global_by_ofnode()
Also add device_find_global_by_ofnode() that also find a device based on
the OF node, but doesn't probe the device.
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Diffstat (limited to 'drivers/core/device.c')
-rw-r--r-- | drivers/core/device.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c index 207d566b71..fd59fe1e0f 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -594,16 +594,16 @@ int device_get_child_by_of_offset(struct udevice *parent, int node, return device_get_device_tail(dev, ret, devp); } -static struct udevice *_device_find_global_by_of_offset(struct udevice *parent, - int of_offset) +static struct udevice *_device_find_global_by_ofnode(struct udevice *parent, + ofnode ofnode) { struct udevice *dev, *found; - if (dev_of_offset(parent) == of_offset) + if (ofnode_equal(dev_ofnode(parent), ofnode)) return parent; list_for_each_entry(dev, &parent->child_head, sibling_node) { - found = _device_find_global_by_of_offset(dev, of_offset); + found = _device_find_global_by_ofnode(dev, ofnode); if (found) return found; } @@ -611,11 +611,18 @@ static struct udevice *_device_find_global_by_of_offset(struct udevice *parent, return NULL; } -int device_get_global_by_of_offset(int of_offset, struct udevice **devp) +int device_find_global_by_ofnode(ofnode ofnode, struct udevice **devp) +{ + *devp = _device_find_global_by_ofnode(gd->dm_root, ofnode); + + return *devp ? 0 : -ENOENT; +} + +int device_get_global_by_ofnode(ofnode ofnode, struct udevice **devp) { struct udevice *dev; - dev = _device_find_global_by_of_offset(gd->dm_root, of_offset); + dev = _device_find_global_by_ofnode(gd->dm_root, ofnode); return device_get_device_tail(dev, dev ? 0 : -ENOENT, devp); } |