From: Axel Lin Date: Mon, 16 Apr 2012 10:44:23 +0000 (+0800) Subject: regulator: core: Add checking set_mode callback in regulator_set_optimum_mode X-Git-Tag: v3.5-rc1~177^2~58^2~1 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=854ccbaee7e48734936690a3fd4817c57e98aaad;p=~emulex%2Finfiniband.git regulator: core: Add checking set_mode callback in regulator_set_optimum_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 Signed-off-by: Mark Brown --- diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 5c0c975e5ac..2f0d557a910 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -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) {