aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-10-23 17:26:09 -0600
committerSimon Glass <sjg@chromium.org>2021-11-28 16:51:51 -0700
commit29fe555dec4c18096ab1ddd51398317160359ba1 (patch)
tree071caf2042aaadff4ebe4fb698a2aba4ba4d3b76 /drivers
parent4b030177b6608bc6f2508e023089112e8adb2f4b (diff)
downloadu-boot-29fe555dec4c18096ab1ddd51398317160359ba1.zip
u-boot-29fe555dec4c18096ab1ddd51398317160359ba1.tar.gz
u-boot-29fe555dec4c18096ab1ddd51398317160359ba1.tar.bz2
dm: core: Add a way to count the devices in a uclass
Add a function that returns the number of devices in a uclass. This can be helpful in sizing an array that needs to hold a list of them. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/core/uclass.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 3de5f27..2aa2143 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -794,6 +794,18 @@ int uclass_probe_all(enum uclass_id id)
return 0;
}
+int uclass_id_count(enum uclass_id id)
+{
+ struct udevice *dev;
+ struct uclass *uc;
+ int count = 0;
+
+ uclass_id_foreach_dev(id, dev, uc)
+ count++;
+
+ return count;
+}
+
UCLASS_DRIVER(nop) = {
.id = UCLASS_NOP,
.name = "nop",