diff options
-rw-r--r-- | drivers/regulator/core.c | 30 | ||||
-rw-r--r-- | include/linux/regulator/machine.h | 9 |
2 files changed, 37 insertions, 2 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 51cf2bb37438..eb112d961515 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -2328,7 +2328,37 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, | |||
2328 | goto scrub; | 2328 | goto scrub; |
2329 | 2329 | ||
2330 | /* set supply regulator if it exists */ | 2330 | /* set supply regulator if it exists */ |
2331 | if (init_data->supply_regulator && init_data->supply_regulator_dev) { | ||
2332 | dev_err(dev, | ||
2333 | "Supply regulator specified by both name and dev\n"); | ||
2334 | goto scrub; | ||
2335 | } | ||
2336 | |||
2337 | if (init_data->supply_regulator) { | ||
2338 | struct regulator_dev *r; | ||
2339 | int found = 0; | ||
2340 | |||
2341 | list_for_each_entry(r, ®ulator_list, list) { | ||
2342 | if (strcmp(rdev_get_name(r), | ||
2343 | init_data->supply_regulator) == 0) { | ||
2344 | found = 1; | ||
2345 | break; | ||
2346 | } | ||
2347 | } | ||
2348 | |||
2349 | if (!found) { | ||
2350 | dev_err(dev, "Failed to find supply %s\n", | ||
2351 | init_data->supply_regulator); | ||
2352 | goto scrub; | ||
2353 | } | ||
2354 | |||
2355 | ret = set_supply(rdev, r); | ||
2356 | if (ret < 0) | ||
2357 | goto scrub; | ||
2358 | } | ||
2359 | |||
2331 | if (init_data->supply_regulator_dev) { | 2360 | if (init_data->supply_regulator_dev) { |
2361 | dev_warn(dev, "Uses supply_regulator_dev instead of regulator_supply\n"); | ||
2332 | ret = set_supply(rdev, | 2362 | ret = set_supply(rdev, |
2333 | dev_get_drvdata(init_data->supply_regulator_dev)); | 2363 | dev_get_drvdata(init_data->supply_regulator_dev)); |
2334 | if (ret < 0) | 2364 | if (ret < 0) |
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index 234a8476cba8..e2980287245e 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h | |||
@@ -157,7 +157,11 @@ struct regulator_consumer_supply { | |||
157 | * | 157 | * |
158 | * Initialisation constraints, our supply and consumers supplies. | 158 | * Initialisation constraints, our supply and consumers supplies. |
159 | * | 159 | * |
160 | * @supply_regulator_dev: Parent regulator (if any). | 160 | * @supply_regulator: Parent regulator. Specified using the regulator name |
161 | * as it appears in the name field in sysfs, which can | ||
162 | * be explicitly set using the constraints field 'name'. | ||
163 | * @supply_regulator_dev: Parent regulator (if any) - DEPRECATED in favour | ||
164 | * of supply_regulator. | ||
161 | * | 165 | * |
162 | * @constraints: Constraints. These must be specified for the regulator to | 166 | * @constraints: Constraints. These must be specified for the regulator to |
163 | * be usable. | 167 | * be usable. |
@@ -168,7 +172,8 @@ struct regulator_consumer_supply { | |||
168 | * @driver_data: Data passed to regulator_init. | 172 | * @driver_data: Data passed to regulator_init. |
169 | */ | 173 | */ |
170 | struct regulator_init_data { | 174 | struct regulator_init_data { |
171 | struct device *supply_regulator_dev; /* or NULL for LINE */ | 175 | const char *supply_regulator; /* or NULL for system supply */ |
176 | struct device *supply_regulator_dev; /* or NULL for system supply */ | ||
172 | 177 | ||
173 | struct regulation_constraints constraints; | 178 | struct regulation_constraints constraints; |
174 | 179 | ||