Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: core: Allow regulator_set_voltage for fixed regulators

Make it okay to call regulator_set_voltage on regulators with fixed
voltage if the requested range overlaps the current/configured voltage.

Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Signed-off-by: Mark Brown <broonie@linaro.org>

authored by

Bjorn Andersson and committed by
Mark Brown
c00dc359 d55efa4d

+14
+14
drivers/regulator/core.c
··· 2395 2395 struct regulator_dev *rdev = regulator->rdev; 2396 2396 int ret = 0; 2397 2397 int old_min_uV, old_max_uV; 2398 + int current_uV; 2398 2399 2399 2400 mutex_lock(&rdev->mutex); 2400 2401 ··· 2405 2404 */ 2406 2405 if (regulator->min_uV == min_uV && regulator->max_uV == max_uV) 2407 2406 goto out; 2407 + 2408 + /* If we're trying to set a range that overlaps the current voltage, 2409 + * return succesfully even though the regulator does not support 2410 + * changing the voltage. 2411 + */ 2412 + if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) { 2413 + current_uV = _regulator_get_voltage(rdev); 2414 + if (min_uV <= current_uV && current_uV <= max_uV) { 2415 + regulator->min_uV = min_uV; 2416 + regulator->max_uV = max_uV; 2417 + goto out; 2418 + } 2419 + } 2408 2420 2409 2421 /* sanity check */ 2410 2422 if (!rdev->desc->ops->set_voltage &&