aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
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) {