diff options
author | Mark Brown <broonie@kernel.org> | 2014-09-10 12:03:23 +0100 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-09-10 12:03:23 +0100 |
commit | 3f7c69637511a39f4400dc8312bbcecaa592ab61 (patch) | |
tree | 1d1baaae31beddcbe30177f42023132517711751 /drivers/regulator/of_regulator.c | |
parent | dec38b5ce6a9edb406c60c2670b26a1a4262fdb9 (diff) | |
parent | a0c7b164ad115ec0556dc0904ee2218cbc5cedfa (diff) | |
download | linux-3f7c69637511a39f4400dc8312bbcecaa592ab61.tar.gz linux-3f7c69637511a39f4400dc8312bbcecaa592ab61.tar.bz2 linux-3f7c69637511a39f4400dc8312bbcecaa592ab61.zip |
Merge branch 'topic/of' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator into regulator-isl9305
Diffstat (limited to 'drivers/regulator/of_regulator.c')
-rw-r--r-- | drivers/regulator/of_regulator.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index ee5e67bc8d5b..7a51814abdc5 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -14,8 +14,11 @@ #include <linux/slab.h> #include <linux/of.h> #include <linux/regulator/machine.h> +#include <linux/regulator/driver.h> #include <linux/regulator/of_regulator.h> +#include "internal.h" + static void of_get_regulation_constraints(struct device_node *np, struct regulator_init_data **init_data) { @@ -189,3 +192,51 @@ int of_regulator_match(struct device *dev, struct device_node *node, return count; } EXPORT_SYMBOL_GPL(of_regulator_match); + +struct regulator_init_data *regulator_of_get_init_data(struct device *dev, + const struct regulator_desc *desc, + struct device_node **node) +{ + struct device_node *search, *child; + struct regulator_init_data *init_data = NULL; + const char *name; + + if (!dev->of_node || !desc->of_match) + return NULL; + + if (desc->regulators_node) + search = of_get_child_by_name(dev->of_node, + desc->regulators_node); + else + search = dev->of_node; + + if (!search) { + dev_err(dev, "Failed to find regulator container node\n"); + return NULL; + } + + for_each_child_of_node(search, child) { + name = of_get_property(child, "regulator-compatible", NULL); + if (!name) + name = child->name; + + if (strcmp(desc->of_match, name)) + continue; + + init_data = of_get_regulator_init_data(dev, child); + if (!init_data) { + dev_err(dev, + "failed to parse DT for regulator %s\n", + child->name); + break; + } + + of_node_get(child); + *node = child; + break; + } + + of_node_put(search); + + return init_data; +} |