Skip to content

Commit

Permalink
regulator: add regulator_bulk_force_disable function
Browse files Browse the repository at this point in the history
This patch allows consumers to forcibly disable multiple regulator
clients in a single API call.

Signed-off-by: Donggeun Kim <dg77.kim@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Donggeun Kim authored and Mark Brown committed Jan 3, 2012
1 parent 1bb50b2 commit e1de2f4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
37 changes: 37 additions & 0 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2490,6 +2490,43 @@ int regulator_bulk_disable(int num_consumers,
}
EXPORT_SYMBOL_GPL(regulator_bulk_disable);

/**
* regulator_bulk_force_disable - force disable multiple regulator consumers
*
* @num_consumers: Number of consumers
* @consumers: Consumer data; clients are stored here.
* @return 0 on success, an errno on failure
*
* This convenience API allows consumers to forcibly disable multiple regulator
* clients in a single API call.
* NOTE: This should be used for situations when device damage will
* likely occur if the regulators are not disabled (e.g. over temp).
* Although regulator_force_disable function call for some consumers can
* return error numbers, the function is called for all consumers.
*/
int regulator_bulk_force_disable(int num_consumers,
struct regulator_bulk_data *consumers)
{
int i;
int ret;

for (i = 0; i < num_consumers; i++)
consumers[i].ret =
regulator_force_disable(consumers[i].consumer);

for (i = 0; i < num_consumers; i++) {
if (consumers[i].ret != 0) {
ret = consumers[i].ret;
goto out;
}
}

return 0;
out:
return ret;
}
EXPORT_SYMBOL_GPL(regulator_bulk_force_disable);

/**
* regulator_bulk_free - free multiple regulator consumers
*
Expand Down
8 changes: 8 additions & 0 deletions include/linux/regulator/consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ int regulator_bulk_enable(int num_consumers,
struct regulator_bulk_data *consumers);
int regulator_bulk_disable(int num_consumers,
struct regulator_bulk_data *consumers);
int regulator_bulk_force_disable(int num_consumers,
struct regulator_bulk_data *consumers);
void regulator_bulk_free(int num_consumers,
struct regulator_bulk_data *consumers);

Expand Down Expand Up @@ -247,6 +249,12 @@ static inline int regulator_bulk_disable(int num_consumers,
return 0;
}

static inline int regulator_bulk_force_disable(int num_consumers,
struct regulator_bulk_data *consumers)
{
return 0;
}

static inline void regulator_bulk_free(int num_consumers,
struct regulator_bulk_data *consumers)
{
Expand Down

0 comments on commit e1de2f4

Please sign in to comment.