dm: core: Use const where possible in device.h 42/268142/1
authorSimon Glass <sjg@chromium.org>
Mon, 27 Jan 2020 15:49:36 +0000 (08:49 -0700)
committerJaehoon Chung <jh80.chung@samsung.com>
Thu, 16 Dec 2021 11:38:45 +0000 (20:38 +0900)
Update this header file to use const devices where possible, to permit
callers to also use const.

Change-Id: I9c0bcba75fee845672234a29dfa7723b61f6bc39
Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/core/device.c
include/dm/device.h

index ace2b1d617abcd4c7cf014cae451402f7eda166c..228f99eeb50b707d8fb7a06e9fc23cde2263cf02 100644 (file)
@@ -597,6 +597,17 @@ int device_get_child(const struct udevice *parent, int index,
        return -ENODEV;
 }
 
+int device_get_child_count(const struct udevice *parent)
+{
+       struct udevice *dev;
+       int count = 0;
+
+       list_for_each_entry(dev, &parent->child_head, sibling_node)
+               count++;
+
+       return count;
+}
+
 int device_find_child_by_seq(const struct udevice *parent, int seq_or_req_seq,
                             bool find_req_seq, struct udevice **devp)
 {
index 3deee4e151159f28df257a36e1bbf208c7b547d7..1e6bd615d17d8ae2f9ed7ae9bbe0913c857bb933 100644 (file)
@@ -411,6 +411,15 @@ const char *dev_get_uclass_name(const struct udevice *dev);
 int device_get_child(const struct udevice *parent, int index,
                     struct udevice **devp);
 
+/**
+ * device_get_child_count() - Get the available child count of a device
+ *
+ * Returns the number of children to a device.
+ *
+ * @parent:    Parent device to check
+ */
+int device_get_child_count(const struct udevice *parent);
+
 /**
  * device_find_child_by_seq() - Find a child device based on a sequence
  *