diff options
author | Krzysztof Kozlowski <k.kozlowski@samsung.com> | 2015-01-05 06:48:42 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-01-08 15:15:45 -0500 |
commit | bfa21a0dfe6915dc85953b5d40ea9dae5fdf205f (patch) | |
tree | a65674f6cf409a546fc2a62c74e3ab25261a4f4d /drivers/regulator | |
parent | 1b3de223385d6bf2ab9bf2e9e80aebb26fedd426 (diff) |
regulator: Allow parsing custom properties when using simplified DT parsing
When drivers use simplified DT parsing method (they provide
'regulator_desc.of_match') they still may want to parse custom
properties for some of the regulators. For example some of the
regulators support GPIO enable control.
Add a driver-supplied callback for such case. This way the regulator
core parses common bindings offloading a lot of code from drivers and
still custom properties may be used.
The callback, called for each parsed regulator, may modify the
'regulator_config' initially passed to regulator_register().
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/core.c | 2 | ||||
-rw-r--r-- | drivers/regulator/internal.h | 2 | ||||
-rw-r--r-- | drivers/regulator/of_regulator.c | 11 |
3 files changed, 14 insertions, 1 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index c13b557a560e..5fae8cabd254 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -3635,7 +3635,7 @@ regulator_register(const struct regulator_desc *regulator_desc, | |||
3635 | return ERR_PTR(-ENOMEM); | 3635 | return ERR_PTR(-ENOMEM); |
3636 | } | 3636 | } |
3637 | 3637 | ||
3638 | init_data = regulator_of_get_init_data(dev, regulator_desc, | 3638 | init_data = regulator_of_get_init_data(dev, regulator_desc, config, |
3639 | &rdev->dev.of_node); | 3639 | &rdev->dev.of_node); |
3640 | if (!init_data) { | 3640 | if (!init_data) { |
3641 | init_data = config->init_data; | 3641 | init_data = config->init_data; |
diff --git a/drivers/regulator/internal.h b/drivers/regulator/internal.h index 80ba2a35a04b..c74ac8734023 100644 --- a/drivers/regulator/internal.h +++ b/drivers/regulator/internal.h | |||
@@ -38,11 +38,13 @@ struct regulator { | |||
38 | #ifdef CONFIG_OF | 38 | #ifdef CONFIG_OF |
39 | struct regulator_init_data *regulator_of_get_init_data(struct device *dev, | 39 | struct regulator_init_data *regulator_of_get_init_data(struct device *dev, |
40 | const struct regulator_desc *desc, | 40 | const struct regulator_desc *desc, |
41 | struct regulator_config *config, | ||
41 | struct device_node **node); | 42 | struct device_node **node); |
42 | #else | 43 | #else |
43 | static inline struct regulator_init_data * | 44 | static inline struct regulator_init_data * |
44 | regulator_of_get_init_data(struct device *dev, | 45 | regulator_of_get_init_data(struct device *dev, |
45 | const struct regulator_desc *desc, | 46 | const struct regulator_desc *desc, |
47 | struct regulator_config *config, | ||
46 | struct device_node **node) | 48 | struct device_node **node) |
47 | { | 49 | { |
48 | return NULL; | 50 | return NULL; |
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 91eaaf010524..24e812c48d93 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c | |||
@@ -270,6 +270,7 @@ EXPORT_SYMBOL_GPL(of_regulator_match); | |||
270 | 270 | ||
271 | struct regulator_init_data *regulator_of_get_init_data(struct device *dev, | 271 | struct regulator_init_data *regulator_of_get_init_data(struct device *dev, |
272 | const struct regulator_desc *desc, | 272 | const struct regulator_desc *desc, |
273 | struct regulator_config *config, | ||
273 | struct device_node **node) | 274 | struct device_node **node) |
274 | { | 275 | { |
275 | struct device_node *search, *child; | 276 | struct device_node *search, *child; |
@@ -307,6 +308,16 @@ struct regulator_init_data *regulator_of_get_init_data(struct device *dev, | |||
307 | break; | 308 | break; |
308 | } | 309 | } |
309 | 310 | ||
311 | if (desc->of_parse_cb) { | ||
312 | if (desc->of_parse_cb(child, desc, config)) { | ||
313 | dev_err(dev, | ||
314 | "driver callback failed to parse DT for regulator %s\n", | ||
315 | child->name); | ||
316 | init_data = NULL; | ||
317 | break; | ||
318 | } | ||
319 | } | ||
320 | |||
310 | of_node_get(child); | 321 | of_node_get(child); |
311 | *node = child; | 322 | *node = child; |
312 | break; | 323 | break; |