mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-28 23:50:26 +09:00
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>
This commit is contained in:
parent
999b204383
commit
7ec9181d6a
@ -49,7 +49,7 @@ u32 spl_boot_device(void)
|
|||||||
debug("node=%d\n", node);
|
debug("node=%d\n", node);
|
||||||
goto fallback;
|
goto fallback;
|
||||||
}
|
}
|
||||||
ret = device_get_global_by_of_offset(node, &dev);
|
ret = device_get_global_by_ofnode(offset_to_ofnode(node), &dev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
debug("device at node %s/%d not found: %d\n", bootdev, node,
|
debug("device at node %s/%d not found: %d\n", bootdev, node,
|
||||||
ret);
|
ret);
|
||||||
|
@ -51,7 +51,7 @@ u32 spl_boot_device(void)
|
|||||||
debug("node=%d\n", node);
|
debug("node=%d\n", node);
|
||||||
goto fallback;
|
goto fallback;
|
||||||
}
|
}
|
||||||
ret = device_get_global_by_of_offset(node, &dev);
|
ret = device_get_global_by_ofnode(offset_to_ofnode(node), &dev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
debug("device at node %s/%d not found: %d\n", bootdev, node,
|
debug("device at node %s/%d not found: %d\n", bootdev, node,
|
||||||
ret);
|
ret);
|
||||||
|
@ -594,16 +594,16 @@ int device_get_child_by_of_offset(struct udevice *parent, int node,
|
|||||||
return device_get_device_tail(dev, ret, devp);
|
return device_get_device_tail(dev, ret, devp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct udevice *_device_find_global_by_of_offset(struct udevice *parent,
|
static struct udevice *_device_find_global_by_ofnode(struct udevice *parent,
|
||||||
int of_offset)
|
ofnode ofnode)
|
||||||
{
|
{
|
||||||
struct udevice *dev, *found;
|
struct udevice *dev, *found;
|
||||||
|
|
||||||
if (dev_of_offset(parent) == of_offset)
|
if (ofnode_equal(dev_ofnode(parent), ofnode))
|
||||||
return parent;
|
return parent;
|
||||||
|
|
||||||
list_for_each_entry(dev, &parent->child_head, sibling_node) {
|
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)
|
if (found)
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
@ -611,11 +611,18 @@ static struct udevice *_device_find_global_by_of_offset(struct udevice *parent,
|
|||||||
return NULL;
|
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;
|
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);
|
return device_get_device_tail(dev, dev ? 0 : -ENOENT, devp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,18 +473,33 @@ int device_get_child_by_of_offset(struct udevice *parent, int of_offset,
|
|||||||
struct udevice **devp);
|
struct udevice **devp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* device_get_global_by_of_offset() - Get a device based on FDT offset
|
* device_find_global_by_ofnode() - Get a device based on ofnode
|
||||||
*
|
*
|
||||||
* Locates a device by its device tree offset, searching globally throughout
|
* Locates a device by its device tree ofnode, searching globally throughout
|
||||||
|
* the all driver model devices.
|
||||||
|
*
|
||||||
|
* The device is NOT probed
|
||||||
|
*
|
||||||
|
* @node: Device tree ofnode to find
|
||||||
|
* @devp: Returns pointer to device if found, otherwise this is set to NULL
|
||||||
|
* @return 0 if OK, -ve on error
|
||||||
|
*/
|
||||||
|
|
||||||
|
int device_find_global_by_ofnode(ofnode node, struct udevice **devp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* device_get_global_by_ofnode() - Get a device based on ofnode
|
||||||
|
*
|
||||||
|
* Locates a device by its device tree ofnode, searching globally throughout
|
||||||
* the all driver model devices.
|
* the all driver model devices.
|
||||||
*
|
*
|
||||||
* The device is probed to activate it ready for use.
|
* The device is probed to activate it ready for use.
|
||||||
*
|
*
|
||||||
* @of_offset: Device tree offset to find
|
* @node: Device tree ofnode to find
|
||||||
* @devp: Returns pointer to device if found, otherwise this is set to NULL
|
* @devp: Returns pointer to device if found, otherwise this is set to NULL
|
||||||
* @return 0 if OK, -ve on error
|
* @return 0 if OK, -ve on error
|
||||||
*/
|
*/
|
||||||
int device_get_global_by_of_offset(int of_offset, struct udevice **devp);
|
int device_get_global_by_ofnode(ofnode node, struct udevice **devp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* device_find_first_child() - Find the first child of a device
|
* device_find_first_child() - Find the first child of a device
|
||||||
|
Loading…
Reference in New Issue
Block a user