From: Laxman Dewangan <ldewangan@nvidia.com>
To: broonie@opensource.wolfsonmicro.com, grant.likely@secretlab.ca,
rob.herring@calxeda.com, arnd@arndb.de, linus.walleij@linaro.org,
lrg@ti.com, lee.jones@linaro.org, swarren@wwwdotorg.org
Cc: devicetree-discuss@lists.ozlabs.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org,
Laxman Dewangan <ldewangan@nvidia.com>
Subject: [PATCH V2 1/3] regulator: dt: regulator match by regulator-compatible
Date: Tue, 19 Jun 2012 19:58:17 +0530 [thread overview]
Message-ID: <1340116099-17629-2-git-send-email-ldewangan@nvidia.com> (raw)
In-Reply-To: <1340116099-17629-1-git-send-email-ldewangan@nvidia.com>
Match the device's regulators with the property of
"regulator-compatible" of each regulator node.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
Changes from V1:
- In place of adding new api, modify the existing api of_regulator_match() to
look regulator-compatible for matching.
drivers/regulator/of_regulator.c | 50 ++++++++++++++++++++++++-------------
1 files changed, 32 insertions(+), 18 deletions(-)
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index e2a7310..7621306 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -92,15 +92,17 @@ struct regulator_init_data *of_get_regulator_init_data(struct device *dev,
EXPORT_SYMBOL_GPL(of_get_regulator_init_data);
/**
- * of_regulator_match - extract regulator init data
+ * of_regulator_match - extract regulator init data when node
+ * property "regulator-compatible" matches with the regulator name.
* @dev: device requesting the data
* @node: parent device node of the regulators
* @matches: match table for the regulators
* @num_matches: number of entries in match table
*
* This function uses a match table specified by the regulator driver and
- * looks up the corresponding init data in the device tree. Note that the
- * match table is modified in place.
+ * looks up the corresponding init data in the device tree if
+ * regulator-compatible matches. Note that the match table is modified
+ * in place.
*
* Returns the number of matches found or a negative error code on failure.
*/
@@ -110,27 +112,39 @@ int of_regulator_match(struct device *dev, struct device_node *node,
{
unsigned int count = 0;
unsigned int i;
+ const char *regulator_comp;
+ struct device_node *child;
if (!dev || !node)
return -EINVAL;
- for (i = 0; i < num_matches; i++) {
- struct of_regulator_match *match = &matches[i];
- struct device_node *child;
-
- child = of_find_node_by_name(node, match->name);
- if (!child)
- continue;
-
- match->init_data = of_get_regulator_init_data(dev, child);
- if (!match->init_data) {
- dev_err(dev, "failed to parse DT for regulator %s\n",
+ for_each_child_of_node(node, child) {
+ regulator_comp = of_get_property(child,
+ "regulator-compatible", NULL);
+ if (!regulator_comp) {
+ dev_err(dev, "regulator-compatible is missing for node %s\n",
child->name);
- return -EINVAL;
+ continue;
+ }
+ for (i = 0; i < num_matches; i++) {
+ struct of_regulator_match *match = &matches[i];
+ if (match->of_node)
+ continue;
+
+ if (strcmp(match->name, regulator_comp))
+ continue;
+
+ match->init_data =
+ of_get_regulator_init_data(dev, child);
+ if (!match->init_data) {
+ dev_err(dev,
+ "failed to parse DT for regulator %s\n",
+ child->name);
+ return -EINVAL;
+ }
+ match->of_node = child;
+ count++;
}
-
- match->of_node = child;
- count++;
}
return count;
--
1.7.1.1
next prev parent reply other threads:[~2012-06-19 14:28 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-19 14:28 [PATCH V2 0/3] regulator: dt: add policy to match regulator with prop "regulator-compatible" Laxman Dewangan
2012-06-19 14:28 ` Laxman Dewangan [this message]
2012-06-19 17:39 ` [PATCH V2 1/3] regulator: dt: regulator match by regulator-compatible Stephen Warren
2012-06-19 14:28 ` [PATCH V2 2/3] regulator: dt: add policy to have property "regulator-compatible" Laxman Dewangan
2012-06-19 17:43 ` Stephen Warren
2012-06-19 17:53 ` Mark Brown
2012-06-19 18:03 ` Stephen Warren
2012-06-19 18:06 ` Mark Brown
2012-06-19 14:28 ` [PATCH V2 3/3] ARM: dts: db8500: add node property "regulator-compatible" regulator node Laxman Dewangan
2012-06-19 16:13 ` Lee Jones
2012-06-19 17:32 ` Stephen Warren
2012-06-20 7:09 ` Lee Jones
2012-06-20 7:39 ` Laxman Dewangan
2012-06-20 8:01 ` Lee Jones
2012-06-20 8:19 ` Laxman Dewangan
2012-06-20 8:56 ` Lee Jones
2012-06-20 10:06 ` Mark Brown
2012-06-20 11:25 ` Lee Jones
2012-06-20 11:27 ` Laxman Dewangan
2012-06-20 11:37 ` Lee Jones
2012-06-20 16:14 ` Stephen Warren
2012-06-19 17:29 ` Stephen Warren
2012-06-20 8:59 ` [PATCH V2 0/3] regulator: dt: add policy to match regulator with prop "regulator-compatible" Linus Walleij
2012-06-20 10:00 ` Mark Brown
2012-06-20 16:23 ` Stephen Warren
2012-06-21 8:02 ` Linus Walleij
2012-06-21 9:53 ` 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=1340116099-17629-2-git-send-email-ldewangan@nvidia.com \
--to=ldewangan@nvidia.com \
--cc=arnd@arndb.de \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@secretlab.ca \
--cc=lee.jones@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@ti.com \
--cc=rob.herring@calxeda.com \
--cc=swarren@wwwdotorg.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;
as well as URLs for NNTP newsgroup(s).