Skip to content

Commit

Permalink
regulator: core: Add checking set_mode callback in regulator_set_opti…
Browse files Browse the repository at this point in the history
…mum_mode

regulator_set_optimum_mode needs set_mode to properly work.
Add checking for set_mode callback in case it may be not implemented.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Axel Lin authored and Mark Brown committed Apr 16, 2012
1 parent 8ac0e95 commit 854ccba
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2335,6 +2335,9 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
*/
ret = -EINVAL;

if (!rdev->desc->ops->set_mode)
goto out;

/* get output voltage */
output_uV = _regulator_get_voltage(rdev);
if (output_uV <= 0) {
Expand Down

0 comments on commit 854ccba

Please sign in to comment.