summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRobin Gong <b38343@freescale.com>2012-03-13 14:50:15 +0800
committerJustin Waters <justin.waters@timesys.com>2012-07-03 16:57:42 -0400
commit2ba378a207e41589eff8b5c6cf1508ffdbf07a4a (patch)
treea05abb219eaaa869ceb4a4cd72a2dcf69f78720c /drivers
parenta2300d717221106446242261f20b4ec9af1958c2 (diff)
ENGR00176649-3 regulator:Support regulator set in sysfs
By default, regulator set is disabled by kernel, but if enable the function we can easily set regulator in sysfs, it's useful for unit test of pfuze regulator. Signed-off-by: Robin Gong <b38343@freescale.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/regulator/core.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index d3e38790906e..bffd22fd415c 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -275,7 +275,23 @@ static ssize_t regulator_uV_show(struct device *dev,
return ret;
}
-static DEVICE_ATTR(microvolts, 0444, regulator_uV_show, NULL);
+static ssize_t regulator_uV_store(struct device *dev,
+ struct device_attribute *attr, char *buf,
+ size_t count)
+{
+ struct regulator_dev *rdev = dev_get_drvdata(dev);
+ ssize_t ret;
+ int uV;
+ uV = simple_strtoul(buf, NULL, 10);
+ mutex_lock(&rdev->mutex);
+ ret = _regulator_do_set_voltage(rdev, uV, uV);
+ if (ret)
+ rdev_err(rdev, "failed to set microvolts!!\n");
+ mutex_unlock(&rdev->mutex);
+
+ return count;
+}
+static DEVICE_ATTR(microvolts, 0666, regulator_uV_show, regulator_uV_store);
static ssize_t regulator_uA_show(struct device *dev,
struct device_attribute *attr, char *buf)