|
@@ -3581,20 +3581,21 @@ static void rdev_init_debugfs(struct regulator_dev *rdev)
|
|
*/
|
|
*/
|
|
struct regulator_dev *
|
|
struct regulator_dev *
|
|
regulator_register(const struct regulator_desc *regulator_desc,
|
|
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 regulation_constraints *constraints = NULL;
|
|
const struct regulator_init_data *init_data;
|
|
const struct regulator_init_data *init_data;
|
|
|
|
+ struct regulator_config *config = NULL;
|
|
static atomic_t regulator_no = ATOMIC_INIT(0);
|
|
static atomic_t regulator_no = ATOMIC_INIT(0);
|
|
struct regulator_dev *rdev;
|
|
struct regulator_dev *rdev;
|
|
struct device *dev;
|
|
struct device *dev;
|
|
int ret, i;
|
|
int ret, i;
|
|
const char *supply = NULL;
|
|
const char *supply = NULL;
|
|
|
|
|
|
- if (regulator_desc == NULL || config == NULL)
|
|
|
|
|
|
+ if (regulator_desc == NULL || cfg == NULL)
|
|
return ERR_PTR(-EINVAL);
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
|
- dev = config->dev;
|
|
|
|
|
|
+ dev = cfg->dev;
|
|
WARN_ON(!dev);
|
|
WARN_ON(!dev);
|
|
|
|
|
|
if (regulator_desc->name == NULL || regulator_desc->ops == NULL)
|
|
if (regulator_desc->name == NULL || regulator_desc->ops == NULL)
|
|
@@ -3624,6 +3625,16 @@ regulator_register(const struct regulator_desc *regulator_desc,
|
|
if (rdev == NULL)
|
|
if (rdev == NULL)
|
|
return ERR_PTR(-ENOMEM);
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * 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,
|
|
init_data = regulator_of_get_init_data(dev, regulator_desc,
|
|
&rdev->dev.of_node);
|
|
&rdev->dev.of_node);
|
|
if (!init_data) {
|
|
if (!init_data) {
|
|
@@ -3752,6 +3763,7 @@ add_dev:
|
|
rdev_init_debugfs(rdev);
|
|
rdev_init_debugfs(rdev);
|
|
out:
|
|
out:
|
|
mutex_unlock(®ulator_list_mutex);
|
|
mutex_unlock(®ulator_list_mutex);
|
|
|
|
+ kfree(config);
|
|
return rdev;
|
|
return rdev;
|
|
|
|
|
|
unset_supplies:
|
|
unset_supplies:
|