mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] regulator: core: Use list_voltage() to read single voltage regulators
@ 2012-08-09 15:45 Mark Brown
  2012-08-09 16:17 ` Stephen Warren
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Brown @ 2012-08-09 15:45 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: Stephen Warren, linux-kernel, 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.

Reported-by: Stephen Warren <swarren@wwwdotorg.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/regulator/core.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 157def1..ff8f544 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -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;
 	}
-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] regulator: core: Use list_voltage() to read single voltage regulators
  2012-08-09 15:45 [PATCH] regulator: core: Use list_voltage() to read single voltage regulators Mark Brown
@ 2012-08-09 16:17 ` Stephen Warren
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Warren @ 2012-08-09 16:17 UTC (permalink / raw)
  To: Mark Brown; +Cc: Liam Girdwood, linux-kernel

On 08/09/2012 09:45 AM, Mark Brown wrote:
> 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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-08-09 16:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-09 15:45 [PATCH] regulator: core: Use list_voltage() to read single voltage regulators Mark Brown
2012-08-09 16:17 ` Stephen Warren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome