dm: core: Add device_foreach_child()

We have a 'safe' version of this function but sometimes it is not needed.
Add a normal version too and update a few places that can use it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
diff --git a/arch/arm/mach-uniphier/pinctrl-glue.c b/arch/arm/mach-uniphier/pinctrl-glue.c
index c4d3b17..b45f72f 100644
--- a/arch/arm/mach-uniphier/pinctrl-glue.c
+++ b/arch/arm/mach-uniphier/pinctrl-glue.c
@@ -13,14 +13,14 @@
 
 int uniphier_pin_init(const char *pinconfig_name)
 {
-	struct udevice *pctldev, *config, *next;
+	struct udevice *pctldev, *config;
 	int ret;
 
 	ret = uclass_first_device(UCLASS_PINCTRL, &pctldev);
 	if (ret)
 		return ret;
 
-	device_foreach_child_safe(config, next, pctldev) {
+	device_foreach_child(config, pctldev) {
 		if (strcmp(config->name, pinconfig_name))
 			continue;
 
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index baaf431..e8f58b3 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -142,9 +142,9 @@
  */
 struct blk_desc *blk_get_by_device(struct udevice *dev)
 {
-	struct udevice *child_dev, *next;
+	struct udevice *child_dev;
 
-	device_foreach_child_safe(child_dev, next, dev) {
+	device_foreach_child(child_dev, dev) {
 		if (device_get_uclass_id(child_dev) != UCLASS_BLK)
 			continue;
 
diff --git a/include/dm/device.h b/include/dm/device.h
index 27a6d7b..d121042 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -680,6 +680,15 @@
 	list_for_each_entry_safe(pos, next, &parent->child_head, sibling_node)
 
 /**
+ * device_foreach_child() - iterate through child devices
+ *
+ * @pos: struct udevice * for the current device
+ * @parent: parent device to scan
+ */
+#define device_foreach_child(pos, parent)	\
+	list_for_each_entry(pos, &parent->child_head, sibling_node)
+
+/**
  * dm_scan_fdt_dev() - Bind child device in a the device tree
  *
  * This handles device which have sub-nodes in the device tree. It scans all