aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2009-01-15 02:03:17 -0500
committerLiam Girdwood <lrg@slimlogic.co.uk>2009-03-31 04:56:20 -0400
commit853116a10544206b6b2cf42ebc9d78fba2668888 (patch)
treebc233aa343638575b36e300e863ce3d477374f57 /drivers
parent93e14baa4494607efe81608725f591e3ba31e3c1 (diff)
regulator: add get_status()
Based on previous LKML discussions: * Update docs for regulator sysfs class attributes to highlight the fact that all current attributes are intended to be control inputs, including notably "state" and "opmode" which previously implied otherwise. * Define a new regulator driver get_status() method, which is the first method reporting regulator outputs instead of inputs. It can report on/off and error status; or instead of simply "on", report the actual operating mode. For the moment, this is a sysfs-only interface, not accessible to regulator clients. Such clients can use the current notification interfaces to detect errors, if the regulator reports them. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/regulator/core.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index f511a406fcaa..0ff95c3ccf5b 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -312,6 +312,47 @@ static ssize_t regulator_state_show(struct device *dev,
312} 312}
313static DEVICE_ATTR(state, 0444, regulator_state_show, NULL); 313static DEVICE_ATTR(state, 0444, regulator_state_show, NULL);
314 314
315static ssize_t regulator_status_show(struct device *dev,
316 struct device_attribute *attr, char *buf)
317{
318 struct regulator_dev *rdev = dev_get_drvdata(dev);
319 int status;
320 char *label;
321
322 status = rdev->desc->ops->get_status(rdev);
323 if (status < 0)
324 return status;
325
326 switch (status) {
327 case REGULATOR_STATUS_OFF:
328 label = "off";
329 break;
330 case REGULATOR_STATUS_ON:
331 label = "on";
332 break;
333 case REGULATOR_STATUS_ERROR:
334 label = "error";
335 break;
336 case REGULATOR_STATUS_FAST:
337 label = "fast";
338 break;
339 case REGULATOR_STATUS_NORMAL:
340 label = "normal";
341 break;
342 case REGULATOR_STATUS_IDLE:
343 label = "idle";
344 break;
345 case REGULATOR_STATUS_STANDBY:
346 label = "standby";
347 break;
348 default:
349 return -ERANGE;
350 }
351
352 return sprintf(buf, "%s\n", label);
353}
354static DEVICE_ATTR(status, 0444, regulator_status_show, NULL);
355
315static ssize_t regulator_min_uA_show(struct device *dev, 356static ssize_t regulator_min_uA_show(struct device *dev,
316 struct device_attribute *attr, char *buf) 357 struct device_attribute *attr, char *buf)
317{ 358{
@@ -1744,6 +1785,11 @@ static int add_regulator_attributes(struct regulator_dev *rdev)
1744 if (status < 0) 1785 if (status < 0)
1745 return status; 1786 return status;
1746 } 1787 }
1788 if (ops->get_status) {
1789 status = device_create_file(dev, &dev_attr_status);
1790 if (status < 0)
1791 return status;
1792 }
1747 1793
1748 /* some attributes are type-specific */ 1794 /* some attributes are type-specific */
1749 if (rdev->desc->type == REGULATOR_CURRENT) { 1795 if (rdev->desc->type == REGULATOR_CURRENT) {