summaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2008-10-10 15:33:20 +0100
committerLiam Girdwood <lrg@slimlogic.co.uk>2008-10-13 21:51:53 +0100
commitbc558a60b58f638ee0188affb627d4894a97b1c7 (patch)
treecbcf03b7f599dd182565be04b5f3d706f5de1c88 /drivers/regulator
parent42fad570b666256a3fd009e23e74cbb365a29ca8 (diff)
downloadkernel-crypto-bc558a60b58f638ee0188affb627d4894a97b1c7.tar.gz
kernel-crypto-bc558a60b58f638ee0188affb627d4894a97b1c7.tar.xz
kernel-crypto-bc558a60b58f638ee0188affb627d4894a97b1c7.zip
regulator: Export regulator name via sysfs
Provide a new file 'name' in the regulator sysfs class with a human readable name for the regulator for use in applications. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/core.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 9a6757decd3..02a774424e8 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -241,6 +241,22 @@ static ssize_t regulator_uA_show(struct device *dev,
return sprintf(buf, "%d\n", _regulator_get_current_limit(rdev));
}
+static ssize_t regulator_name_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct regulator_dev *rdev = dev_get_drvdata(dev);
+ const char *name;
+
+ if (rdev->constraints->name)
+ name = rdev->constraints->name;
+ else if (rdev->desc->name)
+ name = rdev->desc->name;
+ else
+ name = "";
+
+ return sprintf(buf, "%s\n", name);
+}
+
static ssize_t regulator_opmode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -473,7 +489,9 @@ static ssize_t regulator_suspend_standby_state_show(struct device *dev,
else
return sprintf(buf, "disabled\n");
}
+
static struct device_attribute regulator_dev_attrs[] = {
+ __ATTR(name, 0444, regulator_name_show, NULL),
__ATTR(microvolts, 0444, regulator_uV_show, NULL),
__ATTR(microamps, 0444, regulator_uA_show, NULL),
__ATTR(opmode, 0444, regulator_opmode_show, NULL),