regulator: Add regulator_bulk_set_voltage

Add a convenience API to set the voltage on multiple consumers
stored in a struct regulator_bulk_data[] in one API call.

Change-Id: Iaeb5ba8c357a66f1401fb1e142bb03904e8e9c7c
Signed-off-by: Justin Paupore <jpaupore@codeaurora.org>
This commit is contained in:
Justin Paupore 2011-08-16 15:39:01 -07:00 committed by Rohit Vaswani
parent d68c0879b8
commit 001d62d43e
2 changed files with 44 additions and 0 deletions

View file

@ -3533,6 +3533,42 @@ err:
}
EXPORT_SYMBOL_GPL(regulator_bulk_enable);
/**
* regulator_bulk_set_voltage - set voltage for 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 the voted voltage ranges of multiple regulator
* clients to be set in a single API call. If any consumers cannot have their
* voltages set, this function returns WITHOUT withdrawing votes for any
* consumers that have already been set.
*/
int regulator_bulk_set_voltage(int num_consumers,
struct regulator_bulk_data *consumers)
{
int i;
int rc;
for (i = 0; i < num_consumers; i++) {
if (!consumers[i].min_uV && !consumers[i].max_uV)
continue;
rc = regulator_set_voltage(consumers[i].consumer,
consumers[i].min_uV,
consumers[i].max_uV);
if (rc)
goto err;
}
return 0;
err:
pr_err("Failed to set voltage for %s: %d\n", consumers[i].supply, rc);
return rc;
}
EXPORT_SYMBOL_GPL(regulator_bulk_set_voltage);
/**
* regulator_bulk_disable - disable multiple regulator consumers
*

View file

@ -144,6 +144,10 @@ struct regulator;
* using the bulk regulator APIs.
* @consumer: The regulator consumer for the supply. This will be managed
* by the bulk API.
* @min_uV: The minimum requested voltage for the regulator (in microvolts),
* or 0 to not set a voltage.
* @max_uV: The maximum requested voltage for the regulator (in microvolts),
* or 0 to use @min_uV.
*
* The regulator APIs provide a series of regulator_bulk_() API calls as
* a convenience to consumers which require multiple supplies. This
@ -152,6 +156,8 @@ struct regulator;
struct regulator_bulk_data {
const char *supply;
struct regulator *consumer;
int min_uV;
int max_uV;
/* private: Internal use */
int ret;
@ -216,6 +222,8 @@ int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers,
struct regulator_bulk_data *consumers);
int __must_check regulator_bulk_enable(int num_consumers,
struct regulator_bulk_data *consumers);
int regulator_bulk_set_voltage(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,