Skip to contentSkip to conversation

regulator: core: Use list_voltage() to read single voltage regulators

PATCH In review Mark Brown 2 participants 2 messages Aug 9, 2012 Voltage and current regulator framework

lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 regulator: core: Use list_voltage() to read single voltage regulators

If the regulator doesn't supply a way of reading back the voltage but does provide a list_voltage() operation then use that with a selector of zero to read the voltage.

---
 drivers/regulator/core.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/regulator/core.c +2 -0
index 157def1..ff8f544 100644
@@ -2395,6 +2395,8 @@ static int _regulator_get_voltage(struct regulator_dev *rdev)
 		ret = rdev->desc->ops->list_voltage(rdev, sel);
 	} else if (rdev->desc->ops->get_voltage) {
 		ret = rdev->desc->ops->get_voltage(rdev);
+	} else if (rdev->desc->ops->list_voltage) {
+		ret = rdev->desc->ops->list_voltage(rdev, 0);
 	} else {
 		return -EINVAL;
 	}
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 3 lines · Mark Brown

If the regulator doesn't supply a way of reading back the voltage but does provide a list_voltage() operation then use that with a selector of zero to read the voltage.

Ah, this makes sense. The only issue is:

static int add_regulator_attributes(struct regulator_dev *rdev)
...

	if ((ops->get_voltage && ops->get_voltage(rdev) >= 0) ||
	    (ops->get_voltage_sel && ops->get_voltage_sel(rdev) >= 0)) {
		status = device_create_file(dev, &dev_attr_microvolts);

so the microvolts file doesn't get created.