aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2015-02-07 22:16:22 -0500
committerMark Brown <broonie@kernel.org>2015-02-07 22:16:22 -0500
commitfca8e13f50e604436951ce59736046a79258ec20 (patch)
tree710bcf636a9ca0efafefffcae2009e3a3c107483 /drivers/regulator
parenta9877b606ceb40e5b7e08b62d5f10c65b761dcff (diff)
parentf47531b1aa86e0bef898c1ff810f8486f469b111 (diff)
Merge remote-tracking branch 'regulator/topic/dt-cb' into regulator-next
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/core.c22
-rw-r--r--drivers/regulator/internal.h2
-rw-r--r--drivers/regulator/of_regulator.c11
3 files changed, 30 insertions, 5 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 43644ba52aae..e607bafa7c09 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3561,7 +3561,7 @@ static void rdev_init_debugfs(struct regulator_dev *rdev)
3561/** 3561/**
3562 * regulator_register - register regulator 3562 * regulator_register - register regulator
3563 * @regulator_desc: regulator to register 3563 * @regulator_desc: regulator to register
3564 * @config: runtime configuration for regulator 3564 * @cfg: runtime configuration for regulator
3565 * 3565 *
3566 * Called by regulator drivers to register a regulator. 3566 * Called by regulator drivers to register a regulator.
3567 * Returns a valid pointer to struct regulator_dev on success 3567 * Returns a valid pointer to struct regulator_dev on success
@@ -3569,20 +3569,21 @@ static void rdev_init_debugfs(struct regulator_dev *rdev)
3569 */ 3569 */
3570struct regulator_dev * 3570struct regulator_dev *
3571regulator_register(const struct regulator_desc *regulator_desc, 3571regulator_register(const struct regulator_desc *regulator_desc,
3572 const struct regulator_config *config) 3572 const struct regulator_config *cfg)
3573{ 3573{
3574 const struct regulation_constraints *constraints = NULL; 3574 const struct regulation_constraints *constraints = NULL;
3575 const struct regulator_init_data *init_data; 3575 const struct regulator_init_data *init_data;
3576 struct regulator_config *config = NULL;
3576 static atomic_t regulator_no = ATOMIC_INIT(-1); 3577 static atomic_t regulator_no = ATOMIC_INIT(-1);
3577 struct regulator_dev *rdev; 3578 struct regulator_dev *rdev;
3578 struct device *dev; 3579 struct device *dev;
3579 int ret, i; 3580 int ret, i;
3580 const char *supply = NULL; 3581 const char *supply = NULL;
3581 3582
3582 if (regulator_desc == NULL || config == NULL) 3583 if (regulator_desc == NULL || cfg == NULL)
3583 return ERR_PTR(-EINVAL); 3584 return ERR_PTR(-EINVAL);
3584 3585
3585 dev = config->dev; 3586 dev = cfg->dev;
3586 WARN_ON(!dev); 3587 WARN_ON(!dev);
3587 3588
3588 if (regulator_desc->name == NULL || regulator_desc->ops == NULL) 3589 if (regulator_desc->name == NULL || regulator_desc->ops == NULL)
@@ -3612,7 +3613,17 @@ regulator_register(const struct regulator_desc *regulator_desc,
3612 if (rdev == NULL) 3613 if (rdev == NULL)
3613 return ERR_PTR(-ENOMEM); 3614 return ERR_PTR(-ENOMEM);
3614 3615
3615 init_data = regulator_of_get_init_data(dev, regulator_desc, 3616 /*
3617 * Duplicate the config so the driver could override it after
3618 * parsing init data.
3619 */
3620 config = kmemdup(cfg, sizeof(*cfg), GFP_KERNEL);
3621 if (config == NULL) {
3622 kfree(rdev);
3623 return ERR_PTR(-ENOMEM);
3624 }
3625
3626 init_data = regulator_of_get_init_data(dev, regulator_desc, config,
3616 &rdev->dev.of_node); 3627 &rdev->dev.of_node);
3617 if (!init_data) { 3628 if (!init_data) {
3618 init_data = config->init_data; 3629 init_data = config->init_data;
@@ -3735,6 +3746,7 @@ add_dev:
3735 rdev_init_debugfs(rdev); 3746 rdev_init_debugfs(rdev);
3736out: 3747out:
3737 mutex_unlock(&regulator_list_mutex); 3748 mutex_unlock(&regulator_list_mutex);
3749 kfree(config);
3738 return rdev; 3750 return rdev;
3739 3751
3740unset_supplies: 3752unset_supplies:
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
39struct regulator_init_data *regulator_of_get_init_data(struct device *dev, 39struct 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
43static inline struct regulator_init_data * 44static inline struct regulator_init_data *
44regulator_of_get_init_data(struct device *dev, 45regulator_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
271struct regulator_init_data *regulator_of_get_init_data(struct device *dev, 271struct 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;