linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4/4] regulator/of_get_regulator: add child path to find the regulator supplier
@ 2018-11-12  5:53 zoro
  2018-11-13 18:02 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: zoro @ 2018-11-12  5:53 UTC (permalink / raw)
  To: lgirdwood; +Cc: broonie, linux-kernel, zoro

when the VIR_LDO1 regulator supplier is it's brother,
we can't find the supplier.

example code :
&vir_regulator {
	ldo0_vir: ldo0-virtual {
 		regulator-compatible = "VIR_LDO0";
                regulator-name= "VIR_LDO0";
                regulator-min-microvolt = <1000000>;
                regulator-max-microvolt = <2000000>;
            };
            ldo1_vir: ldo1-virtual {
                regulator-compatible = "VIR_LDO1";
                regulator-name= "VIR_LDO1";
                regulator-min-microvolt = <1000000>;
                regulator-max-microvolt = <3000000>;
                ldo1-supply = <&ldo0_vir>;
            };
	}
	...
}

so we add the child ptah to find the suppier.

Signed-off-by: zoro <long17.cool@163.com>
---
 drivers/regulator/core.c |   33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 2c66b52..d328a84 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -228,6 +228,35 @@ static void regulator_unlock_supply(struct regulator_dev *rdev)
 }
 
 /**
+ * of_get_child_regulator - get a child regulator device node
+ * based on supply name
+ * @parent: Parent device node
+ * @prop_name: Combination regulator supply name and "-supply"
+ *
+ * Traverse all child nodes.
+ * Extract the child regulator device node corresponding to the supply name.
+ * returns the device node corresponding to the regulator if found, else
+ * returns NULL.
+ */
+static struct device_node *of_get_child_regulator(struct device_node *parent,
+	const char *prop_name)
+{
+	struct device_node *regnode = NULL;
+	struct device_node *child = NULL;
+
+	for_each_child_of_node(parent, child) {
+		regnode = of_parse_phandle(child, prop_name, 0);
+		if (!regnode) {
+			regnode = of_get_child_regulator(child, prop_name);
+			if (regnode)
+				return regnode;
+		} else
+			return regnode;
+	}
+	return NULL;
+}
+
+/**
  * of_get_regulator - get a regulator device node based on supply name
  * @dev: Device pointer for the consumer (of regulator) device
  * @supply: regulator supply name
@@ -247,6 +276,10 @@ static struct device_node *of_get_regulator(struct device *dev, const char *supp
 	regnode = of_parse_phandle(dev->of_node, prop_name, 0);
 
 	if (!regnode) {
+		regnode = of_get_child_regulator(dev->of_node, prop_name);
+		if (regnode)
+			return regnode;
+
 		dev_dbg(dev, "Looking up %s property in node %pOF failed\n",
 				prop_name, dev->of_node);
 		return NULL;
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 4/4] regulator/of_get_regulator: add child path to find the regulator supplier
  2018-11-12  5:53 [PATCH 4/4] regulator/of_get_regulator: add child path to find the regulator supplier zoro
@ 2018-11-13 18:02 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2018-11-13 18:02 UTC (permalink / raw)
  To: zoro; +Cc: lgirdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 237 bytes --]

On Mon, Nov 12, 2018 at 01:53:07PM +0800, zoro wrote:
> when the VIR_LDO1 regulator supplier is it's brother,
> we can't find the supplier.

I don't have the rest of this series or a cover letter, what's going on
with dependencies here?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-13 18:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-12  5:53 [PATCH 4/4] regulator/of_get_regulator: add child path to find the regulator supplier zoro
2018-11-13 18:02 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).