mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime.ripard@free-electrons.com>
To: carlo@caione.org, Boris Brezillon <boris@free-electrons.com>,
	Mark Brown <broonie@kernel.org>,
	lgirdwood@gmail.com, lee.jones@linaro.org
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, kevin.z.m.zh@gmail.com,
	sunny@allwinnertech.com, shuge@allwinnertech.com,
	zhuzhenhua@allwinnertech.com,
	Maxime Ripard <maxime.ripard@free-electrons.com>
Subject: [PATCH 1/5] regulator: Allow to pass the device node to regulator_dev_lookup
Date: Wed, 28 May 2014 19:11:05 +0200	[thread overview]
Message-ID: <1401297069-7423-2-git-send-email-maxime.ripard@free-electrons.com> (raw)
In-Reply-To: <1401297069-7423-1-git-send-email-maxime.ripard@free-electrons.com>

For now, regulator_dev_lookup only cares about the of_node field of the struct
device that is passed as as argument.

This is actually an issue whenever we have several regulators subnodes in the
DT, that all belong to the same device, which is usually the case.

Add an extra of_node field that is used first in regulator_dev_lookup that
allows to first lookup in the regulator node itself, and then fallback to the
old behaviour.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 drivers/regulator/core.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 8b6b28b5cfda..3e3954252a23 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -154,7 +154,7 @@ static struct regulator_dev *of_get_regulator(struct device *dev,
 	}
 
 	list_for_each_entry(r, &regulator_list, list)
-		if (r->dev.parent && node == r->dev.of_node)
+		if (r->dev.parent && regnode == r->dev.of_node)
 			return r;
 
 	return ERR_PTR(-EPROBE_DEFER);
@@ -1264,6 +1264,7 @@ static void regulator_supply_alias(struct device **dev, const char **supply)
 }
 
 static struct regulator_dev *regulator_dev_lookup(struct device *dev,
+						  struct device_node *of_node,
 						  const char *supply,
 						  int *ret)
 {
@@ -1273,7 +1274,14 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
 
 	regulator_supply_alias(&dev, &supply);
 
-	/* first do a dt based lookup */
+	/* First, do a lookup against the provided of_node */
+	if (of_node) {
+		r = of_get_regulator(dev, of_node, supply);
+		if (!IS_ERR(r))
+			return r;
+	}
+
+	/* Then, do a lookup based on the device of_node */
 	if (dev && dev->of_node) {
 		r = of_get_regulator(dev, dev->of_node, supply);
 		if (IS_ERR(r)) {
@@ -1332,7 +1340,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
 
 	mutex_lock(&regulator_list_mutex);
 
-	rdev = regulator_dev_lookup(dev, id, &ret);
+	rdev = regulator_dev_lookup(dev, NULL, id, &ret);
 	if (rdev)
 		goto found;
 
@@ -3495,7 +3503,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
 	if (supply) {
 		struct regulator_dev *r;
 
-		r = regulator_dev_lookup(dev, supply, &ret);
+		r = regulator_dev_lookup(dev, NULL, supply, &ret);
 
 		if (ret == -ENODEV) {
 			/*
-- 
1.9.3


  reply	other threads:[~2014-05-28 17:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-28 17:11 [PATCH 0/5] regulator: Enhance AXP209 DT support Maxime Ripard
2014-05-28 17:11 ` Maxime Ripard [this message]
2014-05-28 17:11 ` [PATCH 2/5] regulator: Pass the config device node to regulator_dev_lookup Maxime Ripard
2014-05-28 17:11 ` [PATCH 3/5] regulator: axp20x: Update the bindings to use a local parent regulator Maxime Ripard
2014-05-28 18:50   ` Mark Brown
2014-06-03 13:12     ` Maxime Ripard
2014-06-03 14:43       ` Mark Brown
2014-06-05 14:27         ` Maxime Ripard
2014-06-05 15:49           ` Mark Brown
2014-06-06 16:05             ` Maxime Ripard
2014-08-16 13:58               ` Mark Brown
2014-05-28 17:11 ` [PATCH 4/5] mfd: axp209x: Drop the parent supplies field Maxime Ripard
2014-05-29  7:37   ` Lee Jones
2014-05-28 17:11 ` [PATCH 5/5] ARM: sun7i: cubieboard2: Enable the AXP209 Maxime Ripard
2014-05-28 18:47 ` [PATCH 0/5] regulator: Enhance AXP209 DT support Mark Brown
2014-06-03 13:09   ` Maxime Ripard
2014-06-03 13:56     ` Mark Brown

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=1401297069-7423-2-git-send-email-maxime.ripard@free-electrons.com \
    --to=maxime.ripard@free-electrons.com \
    --cc=boris@free-electrons.com \
    --cc=broonie@kernel.org \
    --cc=carlo@caione.org \
    --cc=kevin.z.m.zh@gmail.com \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shuge@allwinnertech.com \
    --cc=sunny@allwinnertech.com \
    --cc=zhuzhenhua@allwinnertech.com \
    /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®