aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorGregor Boirie <gregor.boirie@parrot.com>2016-03-03 05:44:05 -0500
committerJonathan Cameron <jic23@kernel.org>2016-03-05 10:25:58 -0500
commit63d5d525cbbc8938d9fa3d6d6fbd4183e784b6e9 (patch)
tree1435d337719dc1786c2f203da17964e4e88e5db2 /drivers/iio
parentd3546af67f4937075d0747adb3bf56d3c46b32f0 (diff)
iio:magnetometer:ak8975: 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 ak8975 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')
-rw-r--r--drivers/iio/magnetometer/ak8975.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index 896b13e39dae..72c03d9fbeb2 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -32,6 +32,7 @@
32#include <linux/gpio.h> 32#include <linux/gpio.h>
33#include <linux/of_gpio.h> 33#include <linux/of_gpio.h>
34#include <linux/acpi.h> 34#include <linux/acpi.h>
35#include <linux/regulator/consumer.h>
35 36
36#include <linux/iio/iio.h> 37#include <linux/iio/iio.h>
37#include <linux/iio/sysfs.h> 38#include <linux/iio/sysfs.h>
@@ -379,8 +380,23 @@ static int ak8975_who_i_am(struct i2c_client *client,
379 enum asahi_compass_chipset type) 380 enum asahi_compass_chipset type)
380{ 381{
381 u8 wia_val[2]; 382 u8 wia_val[2];
383 struct regulator *vdd = devm_regulator_get_optional(&client->dev,
384 "vdd");
382 int ret; 385 int ret;
383 386
387 /* Enable attached regulator if any. */
388 if (!IS_ERR(vdd)) {
389 ret = regulator_enable(vdd);
390 if (ret) {
391 dev_err(&client->dev, "Failed to enable Vdd supply\n");
392 return ret;
393 }
394 } else {
395 ret = PTR_ERR(vdd);
396 if (ret != -ENODEV)
397 return ret;
398 }
399
384 /* 400 /*
385 * Signature for each device: 401 * Signature for each device:
386 * Device | WIA1 | WIA2 402 * Device | WIA1 | WIA2