diff options
author | Jacek Anaszewski <j.anaszewski@samsung.com> | 2013-05-07 11:41:00 +0100 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-05-22 22:16:48 +0100 |
commit | f4b7f751c6fd2bd7e6d3a83385ee292c39995bdb (patch) | |
tree | 17a916b8e7917ca52ac1144443184e87637914b2 /drivers/iio | |
parent | e64e7d5c8c86ead27ed51a95687ba8327a9c4d2a (diff) |
iio:ak8975 Add support for gpios DT property
Add support for parsing 'gpios' property when initializing
from oftree.
This patch adds also the binding documentation file.
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/magnetometer/ak8975.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index af6c320a534..d75cc23e8ae 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -29,6 +29,7 @@ #include <linux/delay.h> #include <linux/gpio.h> +#include <linux/of_gpio.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h> @@ -384,10 +385,15 @@ static int ak8975_probe(struct i2c_client *client, int err; /* Grab and set up the supplied GPIO. */ - if (client->dev.platform_data == NULL) - eoc_gpio = -1; - else + if (client->dev.platform_data) eoc_gpio = *(int *)(client->dev.platform_data); + else if (client->dev.of_node) + eoc_gpio = of_get_gpio(client->dev.of_node, 0); + else + eoc_gpio = -1; + + if (eoc_gpio == -EPROBE_DEFER) + return -EPROBE_DEFER; /* We may not have a GPIO based IRQ to scan, that is fine, we will poll if so */ |