mirror of
https://xff.cz/git/u-boot/
synced 2025-10-02 07:51:17 +02:00
dm: core: Add device children and sibling functions
Add some utility functions to check for children and for the last sibling in a device's parent. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de>
This commit is contained in:
@@ -490,3 +490,31 @@ fdt_addr_t dev_get_addr(struct udevice *dev)
|
|||||||
return FDT_ADDR_T_NONE;
|
return FDT_ADDR_T_NONE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool device_has_children(struct udevice *dev)
|
||||||
|
{
|
||||||
|
return !list_empty(&dev->child_head);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool device_has_active_children(struct udevice *dev)
|
||||||
|
{
|
||||||
|
struct udevice *child;
|
||||||
|
|
||||||
|
for (device_find_first_child(dev, &child);
|
||||||
|
child;
|
||||||
|
device_find_next_child(&child)) {
|
||||||
|
if (device_active(child))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool device_is_last_sibling(struct udevice *dev)
|
||||||
|
{
|
||||||
|
struct udevice *parent = dev->parent;
|
||||||
|
|
||||||
|
if (!parent)
|
||||||
|
return false;
|
||||||
|
return list_is_last(&dev->sibling_node, &parent->child_head);
|
||||||
|
}
|
||||||
|
@@ -380,4 +380,34 @@ int device_find_next_child(struct udevice **devp);
|
|||||||
*/
|
*/
|
||||||
fdt_addr_t dev_get_addr(struct udevice *dev);
|
fdt_addr_t dev_get_addr(struct udevice *dev);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* device_has_children() - check if a device has any children
|
||||||
|
*
|
||||||
|
* @dev: Device to check
|
||||||
|
* @return true if the device has one or more children
|
||||||
|
*/
|
||||||
|
bool device_has_children(struct udevice *dev);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* device_has_active_children() - check if a device has any active children
|
||||||
|
*
|
||||||
|
* @dev: Device to check
|
||||||
|
* @return true if the device has one or more children and at least one of
|
||||||
|
* them is active (probed).
|
||||||
|
*/
|
||||||
|
bool device_has_active_children(struct udevice *dev);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* device_is_last_sibling() - check if a device is the last sibling
|
||||||
|
*
|
||||||
|
* This function can be useful for display purposes, when special action needs
|
||||||
|
* to be taken when displaying the last sibling. This can happen when a tree
|
||||||
|
* view of devices is being displayed.
|
||||||
|
*
|
||||||
|
* @dev: Device to check
|
||||||
|
* @return true if there are no more siblings after this one - i.e. is it
|
||||||
|
* last in the list.
|
||||||
|
*/
|
||||||
|
bool device_is_last_sibling(struct udevice *dev);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user