mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: zoro <long17.cool@163.com>
To: lgirdwood@gmail.com
Cc: broonie@kernel.org, linux-kernel@vger.kernel.org,
	zoro <long17.cool@163.com>
Subject: [PATCH] regulator/of_get_regulator: add child path to find the regulator supplier
Date: Thu,  8 Nov 2018 13:40:35 +0800	[thread overview]
Message-ID: <1541655635-11574-1-git-send-email-long17.cool@163.com> (raw)

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>;
            };
            ...
        };

when the VIR_LDO1 regulator supplier is it's brother,
we can't find the supplier.
so we add the child ptah to find the suppier.

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

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 2c66b52..5dbfdba 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -239,6 +239,7 @@ static void regulator_unlock_supply(struct regulator_dev *rdev)
 static struct device_node *of_get_regulator(struct device *dev, const char *supply)
 {
 	struct device_node *regnode = NULL;
+	struct device_node *child = NULL;
 	char prop_name[32]; /* 32 is max size of property name */
 
 	dev_dbg(dev, "Looking up %s-supply from device tree\n", supply);
@@ -247,6 +248,11 @@ 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) {
+		for_each_child_of_node(dev->of_node, child) {
+			regnode = of_parse_phandle(child, prop_name, 0);
+			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


             reply	other threads:[~2018-11-08  5:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-08  5:40 zoro [this message]
2018-12-13 17:53 ` Mark Brown
2018-11-14  9:38 zoro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1541655635-11574-1-git-send-email-long17.cool@163.com \
    --to=long17.cool@163.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®