diff options
-rw-r--r-- | drivers/regulator/core.c | 37 | ||||
-rw-r--r-- | include/linux/regulator/consumer.h | 8 |
2 files changed, 45 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index eb750a1ed7fe..ca86f39a0fdc 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -2491,6 +2491,43 @@ err: | |||
2491 | EXPORT_SYMBOL_GPL(regulator_bulk_disable); | 2491 | EXPORT_SYMBOL_GPL(regulator_bulk_disable); |
2492 | 2492 | ||
2493 | /** | 2493 | /** |
2494 | * regulator_bulk_force_disable - force disable multiple regulator consumers | ||
2495 | * | ||
2496 | * @num_consumers: Number of consumers | ||
2497 | * @consumers: Consumer data; clients are stored here. | ||
2498 | * @return 0 on success, an errno on failure | ||
2499 | * | ||
2500 | * This convenience API allows consumers to forcibly disable multiple regulator | ||
2501 | * clients in a single API call. | ||
2502 | * NOTE: This should be used for situations when device damage will | ||
2503 | * likely occur if the regulators are not disabled (e.g. over temp). | ||
2504 | * Although regulator_force_disable function call for some consumers can | ||
2505 | * return error numbers, the function is called for all consumers. | ||
2506 | */ | ||
2507 | int regulator_bulk_force_disable(int num_consumers, | ||
2508 | struct regulator_bulk_data *consumers) | ||
2509 | { | ||
2510 | int i; | ||
2511 | int ret; | ||
2512 | |||
2513 | for (i = 0; i < num_consumers; i++) | ||
2514 | consumers[i].ret = | ||
2515 | regulator_force_disable(consumers[i].consumer); | ||
2516 | |||
2517 | for (i = 0; i < num_consumers; i++) { | ||
2518 | if (consumers[i].ret != 0) { | ||
2519 | ret = consumers[i].ret; | ||
2520 | goto out; | ||
2521 | } | ||
2522 | } | ||
2523 | |||
2524 | return 0; | ||
2525 | out: | ||
2526 | return ret; | ||
2527 | } | ||
2528 | EXPORT_SYMBOL_GPL(regulator_bulk_force_disable); | ||
2529 | |||
2530 | /** | ||
2494 | * regulator_bulk_free - free multiple regulator consumers | 2531 | * regulator_bulk_free - free multiple regulator consumers |
2495 | * | 2532 | * |
2496 | * @num_consumers: Number of consumers | 2533 | * @num_consumers: Number of consumers |
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index 889ab5aaa85b..f2698a0edfc4 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h | |||
@@ -149,6 +149,8 @@ int regulator_bulk_enable(int num_consumers, | |||
149 | struct regulator_bulk_data *consumers); | 149 | struct regulator_bulk_data *consumers); |
150 | int regulator_bulk_disable(int num_consumers, | 150 | int regulator_bulk_disable(int num_consumers, |
151 | struct regulator_bulk_data *consumers); | 151 | struct regulator_bulk_data *consumers); |
152 | int regulator_bulk_force_disable(int num_consumers, | ||
153 | struct regulator_bulk_data *consumers); | ||
152 | void regulator_bulk_free(int num_consumers, | 154 | void regulator_bulk_free(int num_consumers, |
153 | struct regulator_bulk_data *consumers); | 155 | struct regulator_bulk_data *consumers); |
154 | 156 | ||
@@ -247,6 +249,12 @@ static inline int regulator_bulk_disable(int num_consumers, | |||
247 | return 0; | 249 | return 0; |
248 | } | 250 | } |
249 | 251 | ||
252 | static inline int regulator_bulk_force_disable(int num_consumers, | ||
253 | struct regulator_bulk_data *consumers) | ||
254 | { | ||
255 | return 0; | ||
256 | } | ||
257 | |||
250 | static inline void regulator_bulk_free(int num_consumers, | 258 | static inline void regulator_bulk_free(int num_consumers, |
251 | struct regulator_bulk_data *consumers) | 259 | struct regulator_bulk_data *consumers) |
252 | { | 260 | { |