of: spmi: Verify that nodes are available before creating devices

Device Tree allows for devices to be specified as disabled.
This is useful to override SoC specific configuration on boards
that may not have this device.

Change-Id: I77490f6d2f2634c526cf01a2b0da029ff0d51ef0
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
diff --git a/drivers/of/of_spmi.c b/drivers/of/of_spmi.c
index 2602f8c..61085c9 100644
--- a/drivers/of/of_spmi.c
+++ b/drivers/of/of_spmi.c
@@ -203,12 +203,18 @@
 	struct device_node *node;
 	int rc, i, num_dev_node = 0;
 
+	if (!of_device_is_available(container))
+		return;
+
 	/*
 	 * Count the total number of device_nodes so we know how much
 	 * device_store to allocate.
 	 */
-	for_each_child_of_node(container, node)
+	for_each_child_of_node(container, node) {
+		if (!of_device_is_available(node))
+			continue;
 		num_dev_node++;
+	}
 
 	rc = of_spmi_alloc_device_store(d_info, num_dev_node);
 	if (rc) {
@@ -219,6 +225,8 @@
 
 	i = 0;
 	for_each_child_of_node(container, node) {
+		if (!of_device_is_available(node))
+			continue;
 		of_spmi_init_resource(&r_info, node);
 		of_spmi_sum_node_resources(&r_info, 1);
 		rc = of_spmi_allocate_node_resources(d_info, &r_info, i);
@@ -256,6 +264,9 @@
 	for_each_child_of_node(container, node) {
 		struct of_spmi_res_info r_info;
 
+		if (!of_device_is_available(node))
+			continue;
+
 		/**
 		 * Check to see if this node contains children which
 		 * should be all created as the same spmi_device.
@@ -356,6 +367,9 @@
 				continue;
 			}
 
+			if (!of_device_is_available(node))
+				continue;
+
 			rc = of_spmi_alloc_device_store(&d_info, 1);
 			if (rc) {
 				dev_err(&ctrl->dev, "%s: unable to allocate"