Skip to contentSkip to conversation

regulator: core: Add checking set_mode callback in regulator_set_optimum_mode

PATCH Superseded Axel Lin 2 participants 2 messages Apr 13, 2012 – Apr 14, 2012 Voltage and current regulator framework

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 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.

---
 drivers/regulator/core.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/regulator/core.c +5 -0
index 1bd71a8..f241671 100644
@@ -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) {
Signature · 1 line
1.7.5.4
#1 lore raw
Quoted 5 lines · Axel Lin
drivers/regulator/core.c +0 -0
index 1bd71a8..f241671 100644

drivers/regulator/core.c int regulator_set_optimum_mode(struct regulator *regulator, int uA_load) · line 2348

Quoted 9 lines
drivers/regulator/core.c +5 -0
@@ -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 */

regulator_set_mode() just returns an error silently if there isn't a set_mode() op. Why print an error in this case?

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.