aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Martinez Canillas <javier.martinez@collabora.co.uk>2014-11-10 08:43:53 -0500
committerMark Brown <broonie@kernel.org>2014-11-26 13:58:14 -0500
commit072e78b12bf5182a3e2e460388214a291023ef1c (patch)
treedea7a9970709db752d8b998adcc5615e844ddb87
parent87e1e0f29f703e91c54e81f05d831432ec659dde (diff)
regulator: of: Add regulator desc param to of_get_regulator_init_data()
The of_get_regulator_init_data() function is used to extract the regulator init_data but information on how to extract certain data is defined in the static regulator descriptor (e.g: how to map the hardware operating modes). Add a const struct regulator_desc * parameter to the function signature so the parsing logic could use the information in the struct regulator_desc. of_get_regulator_init_data() relies on of_get_regulation_constraints() to actually extract the init_data so it has to pass the struct regulator_desc but that is modified on a later patch. Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/regulator/88pm8607.c3
-rw-r--r--drivers/regulator/anatop-regulator.c5
-rw-r--r--drivers/regulator/arizona-ldo1.c8
-rw-r--r--drivers/regulator/arizona-micsupp.c8
-rw-r--r--drivers/regulator/da9052-regulator.c3
-rw-r--r--drivers/regulator/da9210-regulator.c2
-rw-r--r--drivers/regulator/fan53555.c17
-rw-r--r--drivers/regulator/fixed.c19
-rw-r--r--drivers/regulator/gpio-regulator.c18
-rw-r--r--drivers/regulator/max8952.c2
-rw-r--r--drivers/regulator/max8973-regulator.c3
-rw-r--r--drivers/regulator/max8997.c3
-rw-r--r--drivers/regulator/max8998.c5
-rw-r--r--drivers/regulator/mc13xxx-regulator-core.c3
-rw-r--r--drivers/regulator/of_regulator.c9
-rw-r--r--drivers/regulator/pwm-regulator.c3
-rw-r--r--drivers/regulator/qcom_rpm-regulator.c9
-rw-r--r--drivers/regulator/s5m8767.c3
-rw-r--r--drivers/regulator/sky81452-regulator.c2
-rw-r--r--drivers/regulator/stw481x-vmmc.c3
-rw-r--r--drivers/regulator/ti-abb-regulator.c3
-rw-r--r--drivers/regulator/tps51632-regulator.c43
-rw-r--r--drivers/regulator/tps62360-regulator.c31
-rw-r--r--drivers/regulator/tps65218-regulator.c3
-rw-r--r--drivers/regulator/twl-regulator.c3
-rw-r--r--drivers/regulator/vexpress.c3
-rw-r--r--include/linux/regulator/of_regulator.h8
27 files changed, 130 insertions, 92 deletions
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index 6d77dcd7dcf6..3fe47bd66153 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -330,7 +330,8 @@ static int pm8607_regulator_dt_init(struct platform_device *pdev,
330 for_each_child_of_node(nproot, np) { 330 for_each_child_of_node(nproot, np) {
331 if (!of_node_cmp(np->name, info->desc.name)) { 331 if (!of_node_cmp(np->name, info->desc.name)) {
332 config->init_data = 332 config->init_data =
333 of_get_regulator_init_data(&pdev->dev, np); 333 of_get_regulator_init_data(&pdev->dev, np,
334 &info->desc);
334 config->of_node = np; 335 config->of_node = np;
335 break; 336 break;
336 } 337 }
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index 4f730af70e7c..6eaef9f64420 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -189,17 +189,18 @@ static int anatop_regulator_probe(struct platform_device *pdev)
189 int ret = 0; 189 int ret = 0;
190 u32 val; 190 u32 val;
191 191
192 initdata = of_get_regulator_init_data(dev, np);
193 sreg = devm_kzalloc(dev, sizeof(*sreg), GFP_KERNEL); 192 sreg = devm_kzalloc(dev, sizeof(*sreg), GFP_KERNEL);
194 if (!sreg) 193 if (!sreg)
195 return -ENOMEM; 194 return -ENOMEM;
196 sreg->initdata = initdata;
197 sreg->name = of_get_property(np, "regulator-name", NULL); 195 sreg->name = of_get_property(np, "regulator-name", NULL);
198 rdesc = &sreg->rdesc; 196 rdesc = &sreg->rdesc;
199 rdesc->name = sreg->name; 197 rdesc->name = sreg->name;
200 rdesc->type = REGULATOR_VOLTAGE; 198 rdesc->type = REGULATOR_VOLTAGE;
201 rdesc->owner = THIS_MODULE; 199 rdesc->owner = THIS_MODULE;
202 200
201 initdata = of_get_regulator_init_data(dev, np, rdesc);
202 sreg->initdata = initdata;
203
203 anatop_np = of_get_parent(np); 204 anatop_np = of_get_parent(np);
204 if (!anatop_np) 205 if (!anatop_np)
205 return -ENODEV; 206 return -ENODEV;
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index 4c9db589f6c1..b1eea7f76489 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -179,7 +179,8 @@ static const struct regulator_init_data arizona_ldo1_default = {
179}; 179};
180 180
181static int arizona_ldo1_of_get_pdata(struct arizona *arizona, 181static int arizona_ldo1_of_get_pdata(struct arizona *arizona,
182 struct regulator_config *config) 182 struct regulator_config *config,
183 const struct regulator_desc *desc)
183{ 184{
184 struct arizona_pdata *pdata = &arizona->pdata; 185 struct arizona_pdata *pdata = &arizona->pdata;
185 struct arizona_ldo1 *ldo1 = config->driver_data; 186 struct arizona_ldo1 *ldo1 = config->driver_data;
@@ -194,7 +195,8 @@ static int arizona_ldo1_of_get_pdata(struct arizona *arizona,
194 if (init_node) { 195 if (init_node) {
195 config->of_node = init_node; 196 config->of_node = init_node;
196 197
197 init_data = of_get_regulator_init_data(arizona->dev, init_node); 198 init_data = of_get_regulator_init_data(arizona->dev, init_node,
199 desc);
198 200
199 if (init_data) { 201 if (init_data) {
200 init_data->consumer_supplies = &ldo1->supply; 202 init_data->consumer_supplies = &ldo1->supply;
@@ -257,7 +259,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
257 259
258 if (IS_ENABLED(CONFIG_OF)) { 260 if (IS_ENABLED(CONFIG_OF)) {
259 if (!dev_get_platdata(arizona->dev)) { 261 if (!dev_get_platdata(arizona->dev)) {
260 ret = arizona_ldo1_of_get_pdata(arizona, &config); 262 ret = arizona_ldo1_of_get_pdata(arizona, &config, desc);
261 if (ret < 0) 263 if (ret < 0)
262 return ret; 264 return ret;
263 } 265 }
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c
index ce9aca5f8ee7..c313ef4c3a2f 100644
--- a/drivers/regulator/arizona-micsupp.c
+++ b/drivers/regulator/arizona-micsupp.c
@@ -198,7 +198,8 @@ static const struct regulator_init_data arizona_micsupp_ext_default = {
198}; 198};
199 199
200static int arizona_micsupp_of_get_pdata(struct arizona *arizona, 200static int arizona_micsupp_of_get_pdata(struct arizona *arizona,
201 struct regulator_config *config) 201 struct regulator_config *config,
202 const struct regulator_desc *desc)
202{ 203{
203 struct arizona_pdata *pdata = &arizona->pdata; 204 struct arizona_pdata *pdata = &arizona->pdata;
204 struct arizona_micsupp *micsupp = config->driver_data; 205 struct arizona_micsupp *micsupp = config->driver_data;
@@ -210,7 +211,7 @@ static int arizona_micsupp_of_get_pdata(struct arizona *arizona,
210 if (np) { 211 if (np) {
211 config->of_node = np; 212 config->of_node = np;
212 213
213 init_data = of_get_regulator_init_data(arizona->dev, np); 214 init_data = of_get_regulator_init_data(arizona->dev, np, desc);
214 215
215 if (init_data) { 216 if (init_data) {
216 init_data->consumer_supplies = &micsupp->supply; 217 init_data->consumer_supplies = &micsupp->supply;
@@ -264,7 +265,8 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
264 265
265 if (IS_ENABLED(CONFIG_OF)) { 266 if (IS_ENABLED(CONFIG_OF)) {
266 if (!dev_get_platdata(arizona->dev)) { 267 if (!dev_get_platdata(arizona->dev)) {
267 ret = arizona_micsupp_of_get_pdata(arizona, &config); 268 ret = arizona_micsupp_of_get_pdata(arizona, &config,
269 desc);
268 if (ret < 0) 270 if (ret < 0)
269 return ret; 271 return ret;
270 } 272 }
diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c
index 00033625a09c..3945f1006d23 100644
--- a/drivers/regulator/da9052-regulator.c
+++ b/drivers/regulator/da9052-regulator.c
@@ -436,7 +436,8 @@ static int da9052_regulator_probe(struct platform_device *pdev)
436 if (!of_node_cmp(np->name, 436 if (!of_node_cmp(np->name,
437 regulator->info->reg_desc.name)) { 437 regulator->info->reg_desc.name)) {
438 config.init_data = of_get_regulator_init_data( 438 config.init_data = of_get_regulator_init_data(
439 &pdev->dev, np); 439 &pdev->dev, np,
440 &regulator->info->reg_desc);
440 config.of_node = np; 441 config.of_node = np;
441 break; 442 break;
442 } 443 }
diff --git a/drivers/regulator/da9210-regulator.c b/drivers/regulator/da9210-regulator.c
index 7a320dd11c46..bc6100103f7f 100644
--- a/drivers/regulator/da9210-regulator.c
+++ b/drivers/regulator/da9210-regulator.c
@@ -147,7 +147,7 @@ static int da9210_i2c_probe(struct i2c_client *i2c,
147 147
148 config.dev = &i2c->dev; 148 config.dev = &i2c->dev;
149 config.init_data = pdata ? &pdata->da9210_constraints : 149 config.init_data = pdata ? &pdata->da9210_constraints :
150 of_get_regulator_init_data(dev, dev->of_node); 150 of_get_regulator_init_data(dev, dev->of_node, &da9210_reg);
151 config.driver_data = chip; 151 config.driver_data = chip;
152 config.regmap = chip->regmap; 152 config.regmap = chip->regmap;
153 config.of_node = dev->of_node; 153 config.of_node = dev->of_node;
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index f8e4257aef92..6c43ab2d5121 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -302,7 +302,8 @@ static struct regmap_config fan53555_regmap_config = {
302}; 302};
303 303
304static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev, 304static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev,
305 struct device_node *np) 305 struct device_node *np,
306 const struct regulator_desc *desc)
306{ 307{
307 struct fan53555_platform_data *pdata; 308 struct fan53555_platform_data *pdata;
308 int ret; 309 int ret;
@@ -312,7 +313,7 @@ static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev,
312 if (!pdata) 313 if (!pdata)
313 return NULL; 314 return NULL;
314 315
315 pdata->regulator = of_get_regulator_init_data(dev, np); 316 pdata->regulator = of_get_regulator_init_data(dev, np, desc);
316 317
317 ret = of_property_read_u32(np, "fcs,suspend-voltage-selector", 318 ret = of_property_read_u32(np, "fcs,suspend-voltage-selector",
318 &tmp); 319 &tmp);
@@ -347,20 +348,20 @@ static int fan53555_regulator_probe(struct i2c_client *client,
347 unsigned int val; 348 unsigned int val;
348 int ret; 349 int ret;
349 350
351 di = devm_kzalloc(&client->dev, sizeof(struct fan53555_device_info),
352 GFP_KERNEL);
353 if (!di)
354 return -ENOMEM;
355
350 pdata = dev_get_platdata(&client->dev); 356 pdata = dev_get_platdata(&client->dev);
351 if (!pdata) 357 if (!pdata)
352 pdata = fan53555_parse_dt(&client->dev, np); 358 pdata = fan53555_parse_dt(&client->dev, np, &di->desc);
353 359
354 if (!pdata || !pdata->regulator) { 360 if (!pdata || !pdata->regulator) {
355 dev_err(&client->dev, "Platform data not found!\n"); 361 dev_err(&client->dev, "Platform data not found!\n");
356 return -ENODEV; 362 return -ENODEV;
357 } 363 }
358 364
359 di = devm_kzalloc(&client->dev, sizeof(struct fan53555_device_info),
360 GFP_KERNEL);
361 if (!di)
362 return -ENOMEM;
363
364 di->regulator = pdata->regulator; 365 di->regulator = pdata->regulator;
365 if (client->dev.of_node) { 366 if (client->dev.of_node) {
366 const struct of_device_id *match; 367 const struct of_device_id *match;
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 354105eff1f8..6cfcbc8b6594 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -40,13 +40,15 @@ struct fixed_voltage_data {
40/** 40/**
41 * of_get_fixed_voltage_config - extract fixed_voltage_config structure info 41 * of_get_fixed_voltage_config - extract fixed_voltage_config structure info
42 * @dev: device requesting for fixed_voltage_config 42 * @dev: device requesting for fixed_voltage_config
43 * @desc: regulator description
43 * 44 *
44 * Populates fixed_voltage_config structure by extracting data from device 45 * Populates fixed_voltage_config structure by extracting data from device
45 * tree node, returns a pointer to the populated structure of NULL if memory 46 * tree node, returns a pointer to the populated structure of NULL if memory
46 * alloc fails. 47 * alloc fails.
47 */ 48 */
48static struct fixed_voltage_config * 49static struct fixed_voltage_config *
49of_get_fixed_voltage_config(struct device *dev) 50of_get_fixed_voltage_config(struct device *dev,
51 const struct regulator_desc *desc)
50{ 52{
51 struct fixed_voltage_config *config; 53 struct fixed_voltage_config *config;
52 struct device_node *np = dev->of_node; 54 struct device_node *np = dev->of_node;
@@ -57,7 +59,7 @@ of_get_fixed_voltage_config(struct device *dev)
57 if (!config) 59 if (!config)
58 return ERR_PTR(-ENOMEM); 60 return ERR_PTR(-ENOMEM);
59 61
60 config->init_data = of_get_regulator_init_data(dev, dev->of_node); 62 config->init_data = of_get_regulator_init_data(dev, dev->of_node, desc);
61 if (!config->init_data) 63 if (!config->init_data)
62 return ERR_PTR(-EINVAL); 64 return ERR_PTR(-EINVAL);
63 65
@@ -112,8 +114,14 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
112 struct regulator_config cfg = { }; 114 struct regulator_config cfg = { };
113 int ret; 115 int ret;
114 116
117 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data),
118 GFP_KERNEL);
119 if (!drvdata)
120 return -ENOMEM;
121
115 if (pdev->dev.of_node) { 122 if (pdev->dev.of_node) {
116 config = of_get_fixed_voltage_config(&pdev->dev); 123 config = of_get_fixed_voltage_config(&pdev->dev,
124 &drvdata->desc);
117 if (IS_ERR(config)) 125 if (IS_ERR(config))
118 return PTR_ERR(config); 126 return PTR_ERR(config);
119 } else { 127 } else {
@@ -123,11 +131,6 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
123 if (!config) 131 if (!config)
124 return -ENOMEM; 132 return -ENOMEM;
125 133
126 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data),
127 GFP_KERNEL);
128 if (!drvdata)
129 return -ENOMEM;
130
131 drvdata->desc.name = devm_kstrdup(&pdev->dev, 134 drvdata->desc.name = devm_kstrdup(&pdev->dev,
132 config->supply_name, 135 config->supply_name,
133 GFP_KERNEL); 136 GFP_KERNEL);
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index 989b23b377c0..5c3bcae478b9 100644
--- a/drivers/regulator/gpio-regulator.c
+++ b/drivers/regulator/gpio-regulator.c
@@ -133,7 +133,8 @@ static struct regulator_ops gpio_regulator_voltage_ops = {
133}; 133};
134 134
135static struct gpio_regulator_config * 135static struct gpio_regulator_config *
136of_get_gpio_regulator_config(struct device *dev, struct device_node *np) 136of_get_gpio_regulator_config(struct device *dev, struct device_node *np,
137 const struct regulator_desc *desc)
137{ 138{
138 struct gpio_regulator_config *config; 139 struct gpio_regulator_config *config;
139 const char *regtype; 140 const char *regtype;
@@ -146,7 +147,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
146 if (!config) 147 if (!config)
147 return ERR_PTR(-ENOMEM); 148 return ERR_PTR(-ENOMEM);
148 149
149 config->init_data = of_get_regulator_init_data(dev, np); 150 config->init_data = of_get_regulator_init_data(dev, np, desc);
150 if (!config->init_data) 151 if (!config->init_data)
151 return ERR_PTR(-EINVAL); 152 return ERR_PTR(-EINVAL);
152 153
@@ -243,17 +244,18 @@ static int gpio_regulator_probe(struct platform_device *pdev)
243 struct regulator_config cfg = { }; 244 struct regulator_config cfg = { };
244 int ptr, ret, state; 245 int ptr, ret, state;
245 246
246 if (np) {
247 config = of_get_gpio_regulator_config(&pdev->dev, np);
248 if (IS_ERR(config))
249 return PTR_ERR(config);
250 }
251
252 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data), 247 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data),
253 GFP_KERNEL); 248 GFP_KERNEL);
254 if (drvdata == NULL) 249 if (drvdata == NULL)
255 return -ENOMEM; 250 return -ENOMEM;
256 251
252 if (np) {
253 config = of_get_gpio_regulator_config(&pdev->dev, np,
254 &drvdata->desc);
255 if (IS_ERR(config))
256 return PTR_ERR(config);
257 }
258
257 drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL); 259 drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL);
258 if (drvdata->desc.name == NULL) { 260 if (drvdata->desc.name == NULL) {
259 dev_err(&pdev->dev, "Failed to allocate supply name\n"); 261 dev_err(&pdev->dev, "Failed to allocate supply name\n");
diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c
index f7f9efcfedb7..6e54d786b22c 100644
--- a/drivers/regulator/max8952.c
+++ b/drivers/regulator/max8952.c
@@ -174,7 +174,7 @@ static struct max8952_platform_data *max8952_parse_dt(struct device *dev)
174 if (of_property_read_u32(np, "max8952,ramp-speed", &pd->ramp_speed)) 174 if (of_property_read_u32(np, "max8952,ramp-speed", &pd->ramp_speed))
175 dev_warn(dev, "max8952,ramp-speed property not specified, defaulting to 32mV/us\n"); 175 dev_warn(dev, "max8952,ramp-speed property not specified, defaulting to 32mV/us\n");
176 176
177 pd->reg_data = of_get_regulator_init_data(dev, np); 177 pd->reg_data = of_get_regulator_init_data(dev, np, &regulator);
178 if (!pd->reg_data) { 178 if (!pd->reg_data) {
179 dev_err(dev, "Failed to parse regulator init data\n"); 179 dev_err(dev, "Failed to parse regulator init data\n");
180 return NULL; 180 return NULL;
diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
index dbedf1768db0..c3d55c2db593 100644
--- a/drivers/regulator/max8973-regulator.c
+++ b/drivers/regulator/max8973-regulator.c
@@ -458,7 +458,8 @@ static int max8973_probe(struct i2c_client *client,
458 458
459 config.dev = &client->dev; 459 config.dev = &client->dev;
460 config.init_data = pdata ? pdata->reg_init_data : 460 config.init_data = pdata ? pdata->reg_init_data :
461 of_get_regulator_init_data(&client->dev, client->dev.of_node); 461 of_get_regulator_init_data(&client->dev, client->dev.of_node,
462 &max->desc);
462 config.driver_data = max; 463 config.driver_data = max;
463 config.of_node = client->dev.of_node; 464 config.of_node = client->dev.of_node;
464 config.regmap = max->regmap; 465 config.regmap = max->regmap;
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c
index 9c31e215a521..726fde1d883e 100644
--- a/drivers/regulator/max8997.c
+++ b/drivers/regulator/max8997.c
@@ -953,7 +953,8 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev,
953 953
954 rdata->id = i; 954 rdata->id = i;
955 rdata->initdata = of_get_regulator_init_data(&pdev->dev, 955 rdata->initdata = of_get_regulator_init_data(&pdev->dev,
956 reg_np); 956 reg_np,
957 &regulators[i]);
957 rdata->reg_node = reg_np; 958 rdata->reg_node = reg_np;
958 rdata++; 959 rdata++;
959 } 960 }
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index 961091b46557..59e34a05a4a2 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -686,8 +686,9 @@ static int max8998_pmic_dt_parse_pdata(struct max8998_dev *iodev,
686 continue; 686 continue;
687 687
688 rdata->id = regulators[i].id; 688 rdata->id = regulators[i].id;
689 rdata->initdata = of_get_regulator_init_data( 689 rdata->initdata = of_get_regulator_init_data(iodev->dev,
690 iodev->dev, reg_np); 690 reg_np,
691 &regulators[i]);
691 rdata->reg_node = reg_np; 692 rdata->reg_node = reg_np;
692 ++rdata; 693 ++rdata;
693 } 694 }
diff --git a/drivers/regulator/mc13xxx-regulator-core.c b/drivers/regulator/mc13xxx-regulator-core.c
index afba024953e1..0281c31ae2ed 100644
--- a/drivers/regulator/mc13xxx-regulator-core.c
+++ b/drivers/regulator/mc13xxx-regulator-core.c
@@ -194,7 +194,8 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
194 regulators[i].desc.name)) { 194 regulators[i].desc.name)) {
195 p->id = i; 195 p->id = i;
196 p->init_data = of_get_regulator_init_data( 196 p->init_data = of_get_regulator_init_data(
197 &pdev->dev, child); 197 &pdev->dev, child,
198 &regulators[i].desc);
198 p->node = child; 199 p->node = child;
199 p++; 200 p++;
200 201
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 50be70878d2d..3687a1c38c1c 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -120,13 +120,16 @@ static void of_get_regulation_constraints(struct device_node *np,
120/** 120/**
121 * of_get_regulator_init_data - extract regulator_init_data structure info 121 * of_get_regulator_init_data - extract regulator_init_data structure info
122 * @dev: device requesting for regulator_init_data 122 * @dev: device requesting for regulator_init_data
123 * @node: regulator device node
124 * @desc: regulator description
123 * 125 *
124 * Populates regulator_init_data structure by extracting data from device 126 * Populates regulator_init_data structure by extracting data from device
125 * tree node, returns a pointer to the populated struture or NULL if memory 127 * tree node, returns a pointer to the populated struture or NULL if memory
126 * alloc fails. 128 * alloc fails.
127 */ 129 */
128struct regulator_init_data *of_get_regulator_init_data(struct device *dev, 130struct regulator_init_data *of_get_regulator_init_data(struct device *dev,
129 struct device_node *node) 131 struct device_node *node,
132 const struct regulator_desc *desc)
130{ 133{
131 struct regulator_init_data *init_data; 134 struct regulator_init_data *init_data;
132 135
@@ -218,7 +221,7 @@ int of_regulator_match(struct device *dev, struct device_node *node,
218 continue; 221 continue;
219 222
220 match->init_data = 223 match->init_data =
221 of_get_regulator_init_data(dev, child); 224 of_get_regulator_init_data(dev, child, NULL);
222 if (!match->init_data) { 225 if (!match->init_data) {
223 dev_err(dev, 226 dev_err(dev,
224 "failed to parse DT for regulator %s\n", 227 "failed to parse DT for regulator %s\n",
@@ -265,7 +268,7 @@ struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
265 if (strcmp(desc->of_match, name)) 268 if (strcmp(desc->of_match, name))
266 continue; 269 continue;
267 270
268 init_data = of_get_regulator_init_data(dev, child); 271 init_data = of_get_regulator_init_data(dev, child, desc);
269 if (!init_data) { 272 if (!init_data) {
270 dev_err(dev, 273 dev_err(dev,
271 "failed to parse DT for regulator %s\n", 274 "failed to parse DT for regulator %s\n",
diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c
index d3f55eaea058..91f34ca3a9ac 100644
--- a/drivers/regulator/pwm-regulator.c
+++ b/drivers/regulator/pwm-regulator.c
@@ -149,7 +149,8 @@ static int pwm_regulator_probe(struct platform_device *pdev)
149 return ret; 149 return ret;
150 } 150 }
151 151
152 config.init_data = of_get_regulator_init_data(&pdev->dev, np); 152 config.init_data = of_get_regulator_init_data(&pdev->dev, np,
153 &drvdata->desc);
153 if (!config.init_data) 154 if (!config.init_data)
154 return -ENOMEM; 155 return -ENOMEM;
155 156
diff --git a/drivers/regulator/qcom_rpm-regulator.c b/drivers/regulator/qcom_rpm-regulator.c
index b55cd5b50ebe..dabd28a359dc 100644
--- a/drivers/regulator/qcom_rpm-regulator.c
+++ b/drivers/regulator/qcom_rpm-regulator.c
@@ -643,10 +643,6 @@ static int rpm_reg_probe(struct platform_device *pdev)
643 match = of_match_device(rpm_of_match, &pdev->dev); 643 match = of_match_device(rpm_of_match, &pdev->dev);
644 template = match->data; 644 template = match->data;
645 645
646 initdata = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node);
647 if (!initdata)
648 return -EINVAL;
649
650 vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL); 646 vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL);
651 if (!vreg) { 647 if (!vreg) {
652 dev_err(&pdev->dev, "failed to allocate vreg\n"); 648 dev_err(&pdev->dev, "failed to allocate vreg\n");
@@ -666,6 +662,11 @@ static int rpm_reg_probe(struct platform_device *pdev)
666 return -ENODEV; 662 return -ENODEV;
667 } 663 }
668 664
665 initdata = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node,
666 &vreg->desc);
667 if (!initdata)
668 return -EINVAL;
669
669 key = "reg"; 670 key = "reg";
670 ret = of_property_read_u32(pdev->dev.of_node, key, &val); 671 ret = of_property_read_u32(pdev->dev.of_node, key, &val);
671 if (ret) { 672 if (ret) {
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index 0ab5cbeeb797..26932fe42b47 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -581,7 +581,8 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
581 581
582 rdata->id = i; 582 rdata->id = i;
583 rdata->initdata = of_get_regulator_init_data( 583 rdata->initdata = of_get_regulator_init_data(
584 &pdev->dev, reg_np); 584 &pdev->dev, reg_np,
585 &regulators[i]);
585 rdata->reg_node = reg_np; 586 rdata->reg_node = reg_np;
586 rdata++; 587 rdata++;
587 rmode->id = i; 588 rmode->id = i;
diff --git a/drivers/regulator/sky81452-regulator.c b/drivers/regulator/sky81452-regulator.c
index 97aff0ccd65f..75deae706f84 100644
--- a/drivers/regulator/sky81452-regulator.c
+++ b/drivers/regulator/sky81452-regulator.c
@@ -76,7 +76,7 @@ static struct regulator_init_data *sky81452_reg_parse_dt(struct device *dev)
76 return NULL; 76 return NULL;
77 } 77 }
78 78
79 init_data = of_get_regulator_init_data(dev, np); 79 init_data = of_get_regulator_init_data(dev, np, &sky81452_reg);
80 80
81 of_node_put(np); 81 of_node_put(np);
82 return init_data; 82 return init_data;
diff --git a/drivers/regulator/stw481x-vmmc.c b/drivers/regulator/stw481x-vmmc.c
index a7e152696a02..b4f1696456a7 100644
--- a/drivers/regulator/stw481x-vmmc.c
+++ b/drivers/regulator/stw481x-vmmc.c
@@ -72,7 +72,8 @@ static int stw481x_vmmc_regulator_probe(struct platform_device *pdev)
72 config.regmap = stw481x->map; 72 config.regmap = stw481x->map;
73 config.of_node = pdev->dev.of_node; 73 config.of_node = pdev->dev.of_node;
74 config.init_data = of_get_regulator_init_data(&pdev->dev, 74 config.init_data = of_get_regulator_init_data(&pdev->dev,
75 pdev->dev.of_node); 75 pdev->dev.of_node,
76 &vmmc_regulator);
76 77
77 stw481x->vmmc_regulator = devm_regulator_register(&pdev->dev, 78 stw481x->vmmc_regulator = devm_regulator_register(&pdev->dev,
78 &vmmc_regulator, &config); 79 &vmmc_regulator, &config);
diff --git a/drivers/regulator/ti-abb-regulator.c b/drivers/regulator/ti-abb-regulator.c
index a2dabb575b97..1ef5aba96f17 100644
--- a/drivers/regulator/ti-abb-regulator.c
+++ b/drivers/regulator/ti-abb-regulator.c
@@ -837,7 +837,8 @@ skip_opt:
837 return -EINVAL; 837 return -EINVAL;
838 } 838 }
839 839
840 initdata = of_get_regulator_init_data(dev, pdev->dev.of_node); 840 initdata = of_get_regulator_init_data(dev, pdev->dev.of_node,
841 &abb->rdesc);
841 if (!initdata) { 842 if (!initdata) {
842 dev_err(dev, "%s: Unable to alloc regulator init data\n", 843 dev_err(dev, "%s: Unable to alloc regulator init data\n",
843 __func__); 844 __func__);
diff --git a/drivers/regulator/tps51632-regulator.c b/drivers/regulator/tps51632-regulator.c
index f31f22e3e1bd..c213e37eb69e 100644
--- a/drivers/regulator/tps51632-regulator.c
+++ b/drivers/regulator/tps51632-regulator.c
@@ -221,7 +221,8 @@ static const struct of_device_id tps51632_of_match[] = {
221MODULE_DEVICE_TABLE(of, tps51632_of_match); 221MODULE_DEVICE_TABLE(of, tps51632_of_match);
222 222
223static struct tps51632_regulator_platform_data * 223static struct tps51632_regulator_platform_data *
224 of_get_tps51632_platform_data(struct device *dev) 224 of_get_tps51632_platform_data(struct device *dev,
225 const struct regulator_desc *desc)
225{ 226{
226 struct tps51632_regulator_platform_data *pdata; 227 struct tps51632_regulator_platform_data *pdata;
227 struct device_node *np = dev->of_node; 228 struct device_node *np = dev->of_node;
@@ -230,7 +231,8 @@ static struct tps51632_regulator_platform_data *
230 if (!pdata) 231 if (!pdata)
231 return NULL; 232 return NULL;
232 233
233 pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node); 234 pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node,
235 desc);
234 if (!pdata->reg_init_data) { 236 if (!pdata->reg_init_data) {
235 dev_err(dev, "Not able to get OF regulator init data\n"); 237 dev_err(dev, "Not able to get OF regulator init data\n");
236 return NULL; 238 return NULL;
@@ -248,7 +250,8 @@ static struct tps51632_regulator_platform_data *
248} 250}
249#else 251#else
250static struct tps51632_regulator_platform_data * 252static struct tps51632_regulator_platform_data *
251 of_get_tps51632_platform_data(struct device *dev) 253 of_get_tps51632_platform_data(struct device *dev,
254 const struct regulator_desc *desc)
252{ 255{
253 return NULL; 256 return NULL;
254} 257}
@@ -273,9 +276,25 @@ static int tps51632_probe(struct i2c_client *client,
273 } 276 }
274 } 277 }
275 278
279 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
280 if (!tps)
281 return -ENOMEM;
282
283 tps->dev = &client->dev;
284 tps->desc.name = client->name;
285 tps->desc.id = 0;
286 tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY;
287 tps->desc.min_uV = TPS51632_MIN_VOLTAGE;
288 tps->desc.uV_step = TPS51632_VOLTAGE_STEP_10mV;
289 tps->desc.linear_min_sel = TPS51632_MIN_VSEL;
290 tps->desc.n_voltages = TPS51632_MAX_VSEL + 1;
291 tps->desc.ops = &tps51632_dcdc_ops;
292 tps->desc.type = REGULATOR_VOLTAGE;
293 tps->desc.owner = THIS_MODULE;
294
276 pdata = dev_get_platdata(&client->dev); 295 pdata = dev_get_platdata(&client->dev);
277 if (!pdata && client->dev.of_node) 296 if (!pdata && client->dev.of_node)
278 pdata = of_get_tps51632_platform_data(&client->dev); 297 pdata = of_get_tps51632_platform_data(&client->dev, &tps->desc);
279 if (!pdata) { 298 if (!pdata) {
280 dev_err(&client->dev, "No Platform data\n"); 299 dev_err(&client->dev, "No Platform data\n");
281 return -EINVAL; 300 return -EINVAL;
@@ -296,22 +315,6 @@ static int tps51632_probe(struct i2c_client *client,
296 } 315 }
297 } 316 }
298 317
299 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
300 if (!tps)
301 return -ENOMEM;
302
303 tps->dev = &client->dev;
304 tps->desc.name = client->name;
305 tps->desc.id = 0;
306 tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY;
307 tps->desc.min_uV = TPS51632_MIN_VOLTAGE;
308 tps->desc.uV_step = TPS51632_VOLTAGE_STEP_10mV;
309 tps->desc.linear_min_sel = TPS51632_MIN_VSEL;
310 tps->desc.n_voltages = TPS51632_MAX_VSEL + 1;
311 tps->desc.ops = &tps51632_dcdc_ops;
312 tps->desc.type = REGULATOR_VOLTAGE;
313 tps->desc.owner = THIS_MODULE;
314
315 if (pdata->enable_pwm_dvfs) 318 if (pdata->enable_pwm_dvfs)
316 tps->desc.vsel_reg = TPS51632_VOLTAGE_BASE_REG; 319 tps->desc.vsel_reg = TPS51632_VOLTAGE_BASE_REG;
317 else 320 else
diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c
index a1672044e519..a1fd626c6c96 100644
--- a/drivers/regulator/tps62360-regulator.c
+++ b/drivers/regulator/tps62360-regulator.c
@@ -293,7 +293,8 @@ static const struct regmap_config tps62360_regmap_config = {
293}; 293};
294 294
295static struct tps62360_regulator_platform_data * 295static struct tps62360_regulator_platform_data *
296 of_get_tps62360_platform_data(struct device *dev) 296 of_get_tps62360_platform_data(struct device *dev,
297 const struct regulator_desc *desc)
297{ 298{
298 struct tps62360_regulator_platform_data *pdata; 299 struct tps62360_regulator_platform_data *pdata;
299 struct device_node *np = dev->of_node; 300 struct device_node *np = dev->of_node;
@@ -302,7 +303,8 @@ static struct tps62360_regulator_platform_data *
302 if (!pdata) 303 if (!pdata)
303 return NULL; 304 return NULL;
304 305
305 pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node); 306 pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node,
307 desc);
306 if (!pdata->reg_init_data) { 308 if (!pdata->reg_init_data) {
307 dev_err(dev, "Not able to get OF regulator init data\n"); 309 dev_err(dev, "Not able to get OF regulator init data\n");
308 return NULL; 310 return NULL;
@@ -350,6 +352,17 @@ static int tps62360_probe(struct i2c_client *client,
350 352
351 pdata = dev_get_platdata(&client->dev); 353 pdata = dev_get_platdata(&client->dev);
352 354
355 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
356 if (!tps)
357 return -ENOMEM;
358
359 tps->desc.name = client->name;
360 tps->desc.id = 0;
361 tps->desc.ops = &tps62360_dcdc_ops;
362 tps->desc.type = REGULATOR_VOLTAGE;
363 tps->desc.owner = THIS_MODULE;
364 tps->desc.uV_step = 10000;
365
353 if (client->dev.of_node) { 366 if (client->dev.of_node) {
354 const struct of_device_id *match; 367 const struct of_device_id *match;
355 match = of_match_device(of_match_ptr(tps62360_of_match), 368 match = of_match_device(of_match_ptr(tps62360_of_match),
@@ -360,7 +373,8 @@ static int tps62360_probe(struct i2c_client *client,
360 } 373 }
361 chip_id = (int)(long)match->data; 374 chip_id = (int)(long)match->data;
362 if (!pdata) 375 if (!pdata)
363 pdata = of_get_tps62360_platform_data(&client->dev); 376 pdata = of_get_tps62360_platform_data(&client->dev,
377 &tps->desc);
364 } else if (id) { 378 } else if (id) {
365 chip_id = id->driver_data; 379 chip_id = id->driver_data;
366 } else { 380 } else {
@@ -374,10 +388,6 @@ static int tps62360_probe(struct i2c_client *client,
374 return -EIO; 388 return -EIO;
375 } 389 }
376 390
377 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
378 if (!tps)
379 return -ENOMEM;
380
381 tps->en_discharge = pdata->en_discharge; 391 tps->en_discharge = pdata->en_discharge;
382 tps->en_internal_pulldn = pdata->en_internal_pulldn; 392 tps->en_internal_pulldn = pdata->en_internal_pulldn;
383 tps->vsel0_gpio = pdata->vsel0_gpio; 393 tps->vsel0_gpio = pdata->vsel0_gpio;
@@ -401,13 +411,6 @@ static int tps62360_probe(struct i2c_client *client,
401 return -ENODEV; 411 return -ENODEV;
402 } 412 }
403 413
404 tps->desc.name = client->name;
405 tps->desc.id = 0;
406 tps->desc.ops = &tps62360_dcdc_ops;
407 tps->desc.type = REGULATOR_VOLTAGE;
408 tps->desc.owner = THIS_MODULE;
409 tps->desc.uV_step = 10000;
410
411 tps->regmap = devm_regmap_init_i2c(client, &tps62360_regmap_config); 414 tps->regmap = devm_regmap_init_i2c(client, &tps62360_regmap_config);
412 if (IS_ERR(tps->regmap)) { 415 if (IS_ERR(tps->regmap)) {
413 ret = PTR_ERR(tps->regmap); 416 ret = PTR_ERR(tps->regmap);
diff --git a/drivers/regulator/tps65218-regulator.c b/drivers/regulator/tps65218-regulator.c
index f0a40281b9c1..263cc85d6202 100644
--- a/drivers/regulator/tps65218-regulator.c
+++ b/drivers/regulator/tps65218-regulator.c
@@ -231,7 +231,8 @@ static int tps65218_regulator_probe(struct platform_device *pdev)
231 231
232 template = match->data; 232 template = match->data;
233 id = template->id; 233 id = template->id;
234 init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node); 234 init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node,
235 &regulators[id]);
235 236
236 platform_set_drvdata(pdev, tps); 237 platform_set_drvdata(pdev, tps);
237 238
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 0b4f8660fdb4..dd727bca1983 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -1104,7 +1104,8 @@ static int twlreg_probe(struct platform_device *pdev)
1104 template = match->data; 1104 template = match->data;
1105 id = template->desc.id; 1105 id = template->desc.id;
1106 initdata = of_get_regulator_init_data(&pdev->dev, 1106 initdata = of_get_regulator_init_data(&pdev->dev,
1107 pdev->dev.of_node); 1107 pdev->dev.of_node,
1108 &template->desc);
1108 drvdata = NULL; 1109 drvdata = NULL;
1109 } else { 1110 } else {
1110 id = pdev->id; 1111 id = pdev->id;
diff --git a/drivers/regulator/vexpress.c b/drivers/regulator/vexpress.c
index 02e7267ccf92..5e7c789023a9 100644
--- a/drivers/regulator/vexpress.c
+++ b/drivers/regulator/vexpress.c
@@ -74,7 +74,8 @@ static int vexpress_regulator_probe(struct platform_device *pdev)
74 reg->desc.owner = THIS_MODULE; 74 reg->desc.owner = THIS_MODULE;
75 reg->desc.continuous_voltage_range = true; 75 reg->desc.continuous_voltage_range = true;
76 76
77 init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node); 77 init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node,
78 &reg->desc);
78 if (!init_data) 79 if (!init_data)
79 return -EINVAL; 80 return -EINVAL;
80 81
diff --git a/include/linux/regulator/of_regulator.h b/include/linux/regulator/of_regulator.h
index f9217965aaa3..8d1d136c0fb9 100644
--- a/include/linux/regulator/of_regulator.h
+++ b/include/linux/regulator/of_regulator.h
@@ -6,6 +6,8 @@
6#ifndef __LINUX_OF_REG_H 6#ifndef __LINUX_OF_REG_H
7#define __LINUX_OF_REG_H 7#define __LINUX_OF_REG_H
8 8
9struct regulator_desc;
10
9struct of_regulator_match { 11struct of_regulator_match {
10 const char *name; 12 const char *name;
11 void *driver_data; 13 void *driver_data;
@@ -16,14 +18,16 @@ struct of_regulator_match {
16#if defined(CONFIG_OF) 18#if defined(CONFIG_OF)
17extern struct regulator_init_data 19extern struct regulator_init_data
18 *of_get_regulator_init_data(struct device *dev, 20 *of_get_regulator_init_data(struct device *dev,
19 struct device_node *node); 21 struct device_node *node,
22 const struct regulator_desc *desc);
20extern int of_regulator_match(struct device *dev, struct device_node *node, 23extern int of_regulator_match(struct device *dev, struct device_node *node,
21 struct of_regulator_match *matches, 24 struct of_regulator_match *matches,
22 unsigned int num_matches); 25 unsigned int num_matches);
23#else 26#else
24static inline struct regulator_init_data 27static inline struct regulator_init_data
25 *of_get_regulator_init_data(struct device *dev, 28 *of_get_regulator_init_data(struct device *dev,
26 struct device_node *node) 29 struct device_node *node,
30 const struct regulator_desc *desc)
27{ 31{
28 return NULL; 32 return NULL;
29} 33}