summaryrefslogtreecommitdiff
path: root/drivers/staging/iio/addac
diff options
context:
space:
mode:
authorShreeya Patel <shreeya.patel23498@gmail.com>2018-11-20 22:24:36 +0530
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2018-11-25 11:48:57 +0000
commitc63460c4298f93cdc4e30cda96d21b3583d7e3a0 (patch)
treed280c68933ddfe5577d314f2baa481d7b96af581 /drivers/staging/iio/addac
parentf8f612530e6010cef1971ec986d55d04269d1365 (diff)
Staging: iio: adt7316: Use device tree data to set ldac_pin
Make the driver use device tree instead of the platform data. Hence, use devm_gpiod_get_optional function to get the data from device tree for ldac-pin and accordingly make the needed changes in the driver. Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/staging/iio/addac')
-rw-r--r--drivers/staging/iio/addac/adt7316.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c
index 2f8a122f475d..2ff5a4ef9968 100644
--- a/drivers/staging/iio/addac/adt7316.c
+++ b/drivers/staging/iio/addac/adt7316.c
@@ -177,7 +177,7 @@
struct adt7316_chip_info {
struct adt7316_bus bus;
- u16 ldac_pin;
+ struct gpio_desc *ldac_pin;
u16 int_mask; /* 0x2f */
u8 config1;
u8 config2;
@@ -950,8 +950,8 @@ static ssize_t adt7316_store_update_DAC(struct device *dev,
if (ret)
return -EIO;
} else {
- gpio_set_value(chip->ldac_pin, 0);
- gpio_set_value(chip->ldac_pin, 1);
+ gpiod_set_value(chip->ldac_pin, 0);
+ gpiod_set_value(chip->ldac_pin, 1);
}
return len;
@@ -2122,7 +2122,13 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus,
else
return -ENODEV;
- chip->ldac_pin = adt7316_platform_data[1];
+ chip->ldac_pin = devm_gpiod_get_optional(dev, "adi,ldac", GPIOD_OUT_LOW);
+ if (IS_ERR(chip->ldac_pin)) {
+ ret = PTR_ERR(chip->ldac_pin);
+ dev_err(dev, "Failed to request ldac GPIO: %d\n", ret);
+ return ret;
+ }
+
if (chip->ldac_pin) {
chip->config3 |= ADT7316_DA_EN_VIA_DAC_LDCA;
if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)