[PATCH] regulator: core: Add checking set_mode callback inregulator_set_optimum_mode

From: Axel Lin
Date: Fri Apr 13 2012 - 06:49:35 EST


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@xxxxxxxxx>
---
drivers/regulator/core.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 1bd71a8..f241671 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2340,6 +2340,11 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
*/
ret = -EINVAL;

+ if (!rdev->desc->ops->set_mode) {
+ rdev_err(rdev, "no set_mode operation\n");
+ goto out;
+ }
+
/* get output voltage */
output_uV = _regulator_get_voltage(rdev);
if (output_uV <= 0) {
--
1.7.5.4



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/