of: spmi: Remove excessive loop in dev-container traversal

This factors out some code that is executed twice for no reason.

Change-Id: I562f41b05656dc6d8621859ef5b598869a61c28e
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
diff --git a/drivers/of/of_spmi.c b/drivers/of/of_spmi.c
index 112497c..2602f8c 100644
--- a/drivers/of/of_spmi.c
+++ b/drivers/of/of_spmi.c
@@ -203,7 +203,10 @@
 	struct device_node *node;
 	int rc, i, num_dev_node = 0;
 
-	/* first count the total number of device_nodes */
+	/*
+	 * Count the total number of device_nodes so we know how much
+	 * device_store to allocate.
+	 */
 	for_each_child_of_node(container, node)
 		num_dev_node++;
 
@@ -214,7 +217,6 @@
 		return;
 	}
 
-	/* allocate resources per device_node */
 	i = 0;
 	for_each_child_of_node(container, node) {
 		of_spmi_init_resource(&r_info, node);
@@ -226,17 +228,6 @@
 			of_spmi_free_device_resources(d_info);
 			return;
 		}
-		i++;
-	}
-
-	/**
-	 * Now we need to cycle through again and actually populate
-	 * the resources for each node.
-	 */
-	i = 0;
-	for_each_child_of_node(container, node) {
-		of_spmi_init_resource(&r_info, node);
-		of_spmi_sum_node_resources(&r_info, 1);
 		of_spmi_populate_node_resources(d_info, &r_info, i);
 		i++;
 	}