dm: core: Add a way to obtain a string list

At present we support reading a string list a string at a time. Apart
from being inefficient, this makes it impossible to separate reading of
the devicetree into the of_to_plat() method where it belongs, since any
code which needs access to the string must read it from the devicetree.

Add a function which returns the string property as an array of pointers
to the strings, which is easily used by clients.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 08705ef..709bea2 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -456,6 +456,32 @@
 	}
 }
 
+int ofnode_read_string_list(ofnode node, const char *property,
+			    const char ***listp)
+{
+	const char **prop;
+	int count;
+	int i;
+
+	*listp = NULL;
+	count = ofnode_read_string_count(node, property);
+	if (count < 0)
+		return count;
+	if (!count)
+		return 0;
+
+	prop = calloc(count + 1, sizeof(char *));
+	if (!prop)
+		return -ENOMEM;
+
+	for (i = 0; i < count; i++)
+		ofnode_read_string_index(node, property, i, &prop[i]);
+	prop[count] = NULL;
+	*listp = prop;
+
+	return count;
+}
+
 static void ofnode_from_fdtdec_phandle_args(struct fdtdec_phandle_args *in,
 					    struct ofnode_phandle_args *out)
 {