power_domain: Add power_domain_get_by_name()

Implement power_domain_get_by_name() convenience function which parses
DT property 'power-domain-names' and looks up power domain by matching
name.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Simon Glass <sjg@chromium.org>
diff --git a/drivers/power/domain/power-domain-uclass.c b/drivers/power/domain/power-domain-uclass.c
index 0c5823c..74c33d4 100644
--- a/drivers/power/domain/power-domain-uclass.c
+++ b/drivers/power/domain/power-domain-uclass.c
@@ -80,6 +80,20 @@
 	return 0;
 }
 
+int power_domain_get_by_name(struct udevice *dev,
+			     struct power_domain *power_domain, const char *name)
+{
+	int index;
+
+	index = dev_read_stringlist_search(dev, "power-domain-names", name);
+	if (index < 0) {
+		debug("fdt_stringlist_search() failed: %d\n", index);
+		return index;
+	}
+
+	return power_domain_get_by_index(dev, power_domain, index);
+}
+
 int power_domain_get(struct udevice *dev, struct power_domain *power_domain)
 {
 	return power_domain_get_by_index(dev, power_domain, 0);