mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-08 10:39:08 +00:00
uclass: Add dev_get_uclass_index() to get the uclass/index of a device
This function is the reciprocal of uclass_find_device(). It will be used to print the index information in dm tree dump. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
This commit is contained in:
parent
c3211708cf
commit
e7c865620e
2 changed files with 32 additions and 0 deletions
|
@ -171,6 +171,27 @@ enum uclass_id uclass_get_by_name(const char *name)
|
|||
return UCLASS_INVALID;
|
||||
}
|
||||
|
||||
int dev_get_uclass_index(struct udevice *dev, struct uclass **ucp)
|
||||
{
|
||||
struct udevice *iter;
|
||||
struct uclass *uc = dev->uclass;
|
||||
int i = 0;
|
||||
|
||||
if (list_empty(&uc->dev_head))
|
||||
return -ENODEV;
|
||||
|
||||
list_for_each_entry(iter, &uc->dev_head, uclass_node) {
|
||||
if (iter == dev) {
|
||||
if (ucp)
|
||||
*ucp = uc;
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
int uclass_find_device(enum uclass_id id, int index, struct udevice **devp)
|
||||
{
|
||||
struct uclass *uc;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue