aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2012-06-20 08:23:06 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-07-03 15:19:41 -0400
commit5260cd2bc97318b8477b1d1e99c5a2c53764135b (patch)
treef3f3898f782ac531242c0ffe82eb2f7ef2da69a6 /drivers/regulator
parentda26848afa1111707cb740dbb826b4959f3424b5 (diff)
regulator: dt: regulator match by regulator-compatible
Match the device's regulators with the property of "regulator-compatible" of each regulator node. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Acked-by: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/of_regulator.c51
1 files changed, 33 insertions, 18 deletions
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 68dc3d43dd37..3e4106f2bda9 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,
92EXPORT_SYMBOL_GPL(of_get_regulator_init_data); 92EXPORT_SYMBOL_GPL(of_get_regulator_init_data);
93 93
94/** 94/**
95 * of_regulator_match - extract regulator init data 95 * of_regulator_match - extract regulator init data when node
96 * property "regulator-compatible" matches with the regulator name.
96 * @dev: device requesting the data 97 * @dev: device requesting the data
97 * @node: parent device node of the regulators 98 * @node: parent device node of the regulators
98 * @matches: match table for the regulators 99 * @matches: match table for the regulators
99 * @num_matches: number of entries in match table 100 * @num_matches: number of entries in match table
100 * 101 *
101 * This function uses a match table specified by the regulator driver and 102 * This function uses a match table specified by the regulator driver and
102 * looks up the corresponding init data in the device tree. Note that the 103 * looks up the corresponding init data in the device tree if
103 * match table is modified in place. 104 * regulator-compatible matches. Note that the match table is modified
105 * in place.
104 * 106 *
105 * Returns the number of matches found or a negative error code on failure. 107 * Returns the number of matches found or a negative error code on failure.
106 */ 108 */
@@ -110,27 +112,40 @@ int of_regulator_match(struct device *dev, struct device_node *node,
110{ 112{
111 unsigned int count = 0; 113 unsigned int count = 0;
112 unsigned int i; 114 unsigned int i;
115 const char *regulator_comp;
116 struct device_node *child;
113 117
114 if (!dev || !node) 118 if (!dev || !node)
115 return -EINVAL; 119 return -EINVAL;
116 120
117 for (i = 0; i < num_matches; i++) { 121 for_each_child_of_node(node, child) {
118 struct of_regulator_match *match = &matches[i]; 122 regulator_comp = of_get_property(child,
119 struct device_node *child; 123 "regulator-compatible", NULL);
120 124 if (!regulator_comp) {
121 child = of_find_node_by_name(node, match->name); 125 dev_err(dev, "regulator-compatible is missing for node %s\n",
122 if (!child)
123 continue;
124
125 match->init_data = of_get_regulator_init_data(dev, child);
126 if (!match->init_data) {
127 dev_err(dev, "failed to parse DT for regulator %s\n",
128 child->name); 126 child->name);
129 return -EINVAL; 127 continue;
128 }
129 for (i = 0; i < num_matches; i++) {
130 struct of_regulator_match *match = &matches[i];
131 if (match->of_node)
132 continue;
133
134 if (strcmp(match->name, regulator_comp))
135 continue;
136
137 match->init_data =
138 of_get_regulator_init_data(dev, child);
139 if (!match->init_data) {
140 dev_err(dev,
141 "failed to parse DT for regulator %s\n",
142 child->name);
143 return -EINVAL;
144 }
145 match->of_node = child;
146 count++;
147 break;
130 } 148 }
131
132 match->of_node = child;
133 count++;
134 } 149 }
135 150
136 return count; 151 return count;