Commit 5260cd2b authored by Laxman Dewangan's avatar Laxman Dewangan Committed by Mark Brown

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: default avatarLaxman Dewangan <ldewangan@nvidia.com>
Acked-by: default avatarStephen Warren <swarren@wwwdotorg.org>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent da26848a
...@@ -92,15 +92,17 @@ struct regulator_init_data *of_get_regulator_init_data(struct device *dev, ...@@ -92,15 +92,17 @@ struct regulator_init_data *of_get_regulator_init_data(struct device *dev,
EXPORT_SYMBOL_GPL(of_get_regulator_init_data); 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 * @dev: device requesting the data
* @node: parent device node of the regulators * @node: parent device node of the regulators
* @matches: match table for the regulators * @matches: match table for the regulators
* @num_matches: number of entries in match table * @num_matches: number of entries in match table
* *
* This function uses a match table specified by the regulator driver and * 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 * looks up the corresponding init data in the device tree if
* match table is modified in place. * 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. * Returns the number of matches found or a negative error code on failure.
*/ */
...@@ -110,27 +112,40 @@ int of_regulator_match(struct device *dev, struct device_node *node, ...@@ -110,27 +112,40 @@ int of_regulator_match(struct device *dev, struct device_node *node,
{ {
unsigned int count = 0; unsigned int count = 0;
unsigned int i; unsigned int i;
const char *regulator_comp;
struct device_node *child;
if (!dev || !node) if (!dev || !node)
return -EINVAL; return -EINVAL;
for (i = 0; i < num_matches; i++) { for_each_child_of_node(node, child) {
struct of_regulator_match *match = &matches[i]; regulator_comp = of_get_property(child,
struct device_node *child; "regulator-compatible", NULL);
if (!regulator_comp) {
child = of_find_node_by_name(node, match->name); dev_err(dev, "regulator-compatible is missing for node %s\n",
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",
child->name); 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++;
break;
} }
match->of_node = child;
count++;
} }
return count; return count;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment