diff options
author | Mark Brown <broonie@kernel.org> | 2015-02-08 11:16:22 +0800 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-02-08 11:16:22 +0800 |
commit | fca8e13f50e604436951ce59736046a79258ec20 (patch) | |
tree | 710bcf636a9ca0efafefffcae2009e3a3c107483 /drivers/regulator/core.c | |
parent | a9877b606ceb40e5b7e08b62d5f10c65b761dcff (diff) | |
parent | f47531b1aa86e0bef898c1ff810f8486f469b111 (diff) |
Merge remote-tracking branch 'regulator/topic/dt-cb' into regulator-next
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r-- | drivers/regulator/core.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 43644ba52aa..e607bafa7c0 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3561,7 +3561,7 @@ static void rdev_init_debugfs(struct regulator_dev *rdev) /** * regulator_register - register regulator * @regulator_desc: regulator to register - * @config: runtime configuration for regulator + * @cfg: runtime configuration for regulator * * Called by regulator drivers to register a regulator. * Returns a valid pointer to struct regulator_dev on success @@ -3569,20 +3569,21 @@ static void rdev_init_debugfs(struct regulator_dev *rdev) */ struct regulator_dev * regulator_register(const struct regulator_desc *regulator_desc, - const struct regulator_config *config) + const struct regulator_config *cfg) { const struct regulation_constraints *constraints = NULL; const struct regulator_init_data *init_data; + struct regulator_config *config = NULL; static atomic_t regulator_no = ATOMIC_INIT(-1); struct regulator_dev *rdev; struct device *dev; int ret, i; const char *supply = NULL; - if (regulator_desc == NULL || config == NULL) + if (regulator_desc == NULL || cfg == NULL) return ERR_PTR(-EINVAL); - dev = config->dev; + dev = cfg->dev; WARN_ON(!dev); if (regulator_desc->name == NULL || regulator_desc->ops == NULL) @@ -3612,7 +3613,17 @@ regulator_register(const struct regulator_desc *regulator_desc, if (rdev == NULL) return ERR_PTR(-ENOMEM); - init_data = regulator_of_get_init_data(dev, regulator_desc, + /* + * Duplicate the config so the driver could override it after + * parsing init data. + */ + config = kmemdup(cfg, sizeof(*cfg), GFP_KERNEL); + if (config == NULL) { + kfree(rdev); + return ERR_PTR(-ENOMEM); + } + + init_data = regulator_of_get_init_data(dev, regulator_desc, config, &rdev->dev.of_node); if (!init_data) { init_data = config->init_data; @@ -3735,6 +3746,7 @@ add_dev: rdev_init_debugfs(rdev); out: mutex_unlock(®ulator_list_mutex); + kfree(config); return rdev; unset_supplies: |