regulator: core: Fix continuous_voltage_range case in regulator_can_change_voltage
PATCH 1/1 regulator: core: Fix continuous_voltage_range case in regulator_can_change_voltage
Regulator drivers with continuous_voltage_range flag set allows not setting n_voltages. Thus if continuous_voltage_range is set, check the constraint range instead.
--- drivers/regulator/core.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/regulator/core.c +9 -3
@@ -1885,9 +1885,15 @@ int regulator_can_change_voltage(struct regulator *regulator)struct regulator_dev *rdev = regulator->rdev;if (rdev->constraints && - rdev->constraints->valid_ops_mask ®ULATOR_CHANGE_VOLTAGE && - (rdev->desc->n_voltages - rdev->desc->linear_min_sel) >1 ) -return 1 ; + (rdev->constraints->valid_ops_mask ®ULATOR_CHANGE_VOLTAGE )) { +if (rdev->desc->n_voltages - rdev->desc->linear_min_sel >1 ) +return 1 ; + +if (rdev->desc->continuous_voltage_range && + rdev->constraints->min_uV && rdev->constraints->max_uV && + rdev->constraints->min_uV != rdev->constraints->max_uV) +return 1 ; + }return 0 ; }
Signature · 1 line
1.7.9.5
Hello,
Quoted 23 lines · Axel Lin
Regulator drivers with
continuous_voltage_rangeflag set allows not settingn_voltages. Thus ifcontinuous_voltage_rangeis set, check the constraint range instead.Signed-off-by Axel Lin <[email protected]>--- drivers/regulator/core.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/regulator/core.c +2
-3@@ -1885,9 +1885,15 @@ int regulator_can_change_voltage(struct regulator *regulator)struct regulator_dev *rdev = regulator->rdev;if (rdev->constraints && - rdev->constraints->valid_ops_mask ®ULATOR_CHANGE_VOLTAGE && - (rdev->desc->n_voltages - rdev->desc->linear_min_sel) >1 ) -return 1 ; + (rdev->constraints->valid_ops_mask ®ULATOR_CHANGE_VOLTAGE )) { +if (rdev->desc->n_voltages - rdev->desc->linear_min_sel >1 )
drivers/regulator/core.c int regulator_can_change_voltage(struct regulator *regulator) · line 1899
Quoted 10 lines
drivers/regulator/core.c +7
-0+return 1 ; + +if (rdev->desc->continuous_voltage_range && + rdev->constraints->min_uV && rdev->constraints->max_uV && + rdev->constraints->min_uV != rdev->constraints->max_uV) +return 1 ; + }return 0 ; }
This change looks reasonable, I've missed the fact that there is a support for regulators with continuous voltage range. This change also shows that the n_voltages based workaround used earlier by mmc core was indeed only a hack and regulator_can_change_voltage() approach is much cleaner solution.
Best regards
Signature · 2 lines
Marek Szyprowski Samsung Poland R&D Center
Quoted 5 lines · Marek Szyprowski
This change looks reasonable, I've missed the fact that there is a support for regulators with continuous voltage range. This change also shows that the
n_voltagesbased workaround used earlier by mmc core was indeed only a hack andregulator_can_change_voltage()approach is much cleaner
Both changes are new for v3.8 so it's not surprising that you missed the continuous regulators.
Mark Brown
AppliedQuoted 3 lines · Axel Lin
Regulator drivers with
continuous_voltage_rangeflag set allows not settingn_voltages. Thus ifcontinuous_voltage_rangeis set, check the constraint range instead.
Applied, thanks.