summaryrefslogtreecommitdiffstats
path: root/drivers/iio/pressure
diff options
context:
space:
mode:
authorGrégor Boirie <gregor.boirie@parrot.com>2016-02-17 18:52:51 +0100
committerJonathan Cameron <jic23@kernel.org>2016-02-24 20:40:47 +0000
commit3145229f91916723b07c098c0d88b7d01db6c316 (patch)
tree981c2f175e5b6a7e1b9335b827cf1836bf29730f /drivers/iio/pressure
parenteac635ebad41b4fa960386fd0b042764f275b4d4 (diff)
downloadlinux-3145229f91916723b07c098c0d88b7d01db6c316.tar.bz2
iio:pressure:ms5611: power regulator support
Add support for an optional regulator which, if found into device-tree, will power on device at probing time. The regulator is declared into ms5611 DTS entry as a "vdd-supply" property. Signed-off-by: Gregor Boirie <gregor.boirie@parrot.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/pressure')
-rw-r--r--drivers/iio/pressure/ms5611_core.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/iio/pressure/ms5611_core.c b/drivers/iio/pressure/ms5611_core.c
index acd8e37195bc..992ad8d3b67a 100644
--- a/drivers/iio/pressure/ms5611_core.c
+++ b/drivers/iio/pressure/ms5611_core.c
@@ -16,6 +16,7 @@
#include <linux/module.h>
#include <linux/iio/iio.h>
#include <linux/delay.h>
+#include <linux/regulator/consumer.h>
#include <linux/iio/buffer.h>
#include <linux/iio/triggered_buffer.h>
@@ -290,6 +291,18 @@ static const struct iio_info ms5611_info = {
static int ms5611_init(struct iio_dev *indio_dev)
{
int ret;
+ struct regulator *vdd = devm_regulator_get(indio_dev->dev.parent,
+ "vdd");
+
+ /* Enable attached regulator if any. */
+ if (!IS_ERR(vdd)) {
+ ret = regulator_enable(vdd);
+ if (ret) {
+ dev_err(indio_dev->dev.parent,
+ "failed to enable Vdd supply: %d\n", ret);
+ return ret;
+ }
+ }
ret = ms5611_reset(indio_dev);
if (ret < 0)