X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=drivers%2Fregulator%2Fcore.c;h=d5f84c1b258b38e8d095934bcac5c6d05b013488;hb=1f9cc5f7716d664bfe32289ca61327be01a0a8e3;hp=e872c8be080ed427a2e546efffee50c12acdd9fe;hpb=33f145934025e2f51e866993f09e04a1d1650649;p=deliverable%2Flinux.git diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index e872c8be080e..d5f84c1b258b 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1866,6 +1866,28 @@ int regulator_is_enabled(struct regulator *regulator) } EXPORT_SYMBOL_GPL(regulator_is_enabled); +/** + * regulator_can_change_voltage - check if regulator can change voltage + * @regulator: regulator source + * + * Returns positive if the regulator driver backing the source/client + * can change its voltage, false otherwise. Usefull for detecting fixed + * or dummy regulators and disabling voltage change logic in the client + * driver. + */ +int regulator_can_change_voltage(struct regulator *regulator) +{ + struct regulator_dev *rdev = regulator->rdev; + + if (rdev->constraints && + rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE && + rdev->desc->n_voltages > 1) + return 1; + + return 0; +} +EXPORT_SYMBOL_GPL(regulator_can_change_voltage); + /** * regulator_count_voltages - count regulator_list_voltage() selectors * @regulator: regulator source @@ -1985,6 +2007,11 @@ int regulator_is_supported_voltage(struct regulator *regulator, return ret; } + /* Any voltage within constrains range is fine? */ + if (rdev->desc->continuous_voltage_range) + return min_uV >= rdev->constraints->min_uV && + max_uV <= rdev->constraints->max_uV; + ret = regulator_count_voltages(regulator); if (ret < 0) return ret;