aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/regulator/core.c29
-rw-r--r--include/linux/regulator/consumer.h2
2 files changed, 31 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 68549008582c..e11c2222d9af 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1442,6 +1442,35 @@ int regulator_list_voltage(struct regulator *regulator, unsigned selector)
1442EXPORT_SYMBOL_GPL(regulator_list_voltage); 1442EXPORT_SYMBOL_GPL(regulator_list_voltage);
1443 1443
1444/** 1444/**
1445 * regulator_is_supported_voltage - check if a voltage range can be supported
1446 *
1447 * @regulator: Regulator to check.
1448 * @min_uV: Minimum required voltage in uV.
1449 * @max_uV: Maximum required voltage in uV.
1450 *
1451 * Returns a boolean or a negative error code.
1452 */
1453int regulator_is_supported_voltage(struct regulator *regulator,
1454 int min_uV, int max_uV)
1455{
1456 int i, voltages, ret;
1457
1458 ret = regulator_count_voltages(regulator);
1459 if (ret < 0)
1460 return ret;
1461 voltages = ret;
1462
1463 for (i = 0; i < voltages; i++) {
1464 ret = regulator_list_voltage(regulator, i);
1465
1466 if (ret >= min_uV && ret <= max_uV)
1467 return 1;
1468 }
1469
1470 return 0;
1471}
1472
1473/**
1445 * regulator_set_voltage - set regulator output voltage 1474 * regulator_set_voltage - set regulator output voltage
1446 * @regulator: regulator source 1475 * @regulator: regulator source
1447 * @min_uV: Minimum required voltage in uV 1476 * @min_uV: Minimum required voltage in uV
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index 976b57b6912c..490c5b37b6d7 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -146,6 +146,8 @@ void regulator_bulk_free(int num_consumers,
146 146
147int regulator_count_voltages(struct regulator *regulator); 147int regulator_count_voltages(struct regulator *regulator);
148int regulator_list_voltage(struct regulator *regulator, unsigned selector); 148int regulator_list_voltage(struct regulator *regulator, unsigned selector);
149int regulator_is_supported_voltage(struct regulator *regulator,
150 int min_uV, int max_uV);
149int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV); 151int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
150int regulator_get_voltage(struct regulator *regulator); 152int regulator_get_voltage(struct regulator *regulator);
151int regulator_set_current_limit(struct regulator *regulator, 153int regulator_set_current_limit(struct regulator *regulator,