summaryrefslogtreecommitdiff
path: root/drivers/core/uclass.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/core/uclass.c')
-rw-r--r--drivers/core/uclass.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index d609b170e1..3113d6a56b 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -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;