diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-07-21 11:00:24 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2009-09-22 08:32:38 -0400 |
commit | a7a1ad9066e0266c8a4357ba3dbaeebfb80f531d (patch) | |
tree | 382d5c8a17a4dd44f3193274710caae7721881f8 /drivers/regulator/core.c | |
parent | 5ffbd136e6c51c8d1eec7a4a0c5d2180c81aea30 (diff) |
regulator: Add regulator voltage range check API
Simplify checking of support for voltage ranges by providing an API which
wraps the existing count and list operations.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r-- | drivers/regulator/core.c | 29 |
1 files changed, 29 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) | |||
1442 | EXPORT_SYMBOL_GPL(regulator_list_voltage); | 1442 | EXPORT_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 | */ | ||
1453 | int 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 |