Skip to content

Commit 62265be

Browse files
crazoesintel-lab-lkp
authored andcommitted
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>
1 parent e01eb4f commit 62265be

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

drivers/staging/iio/addac/adt7316.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177

178178
struct adt7316_chip_info {
179179
struct adt7316_bus bus;
180-
u16 ldac_pin;
180+
struct gpio_desc *ldac_pin;
181181
u16 int_mask; /* 0x2f */
182182
u8 config1;
183183
u8 config2;
@@ -950,8 +950,8 @@ static ssize_t adt7316_store_update_DAC(struct device *dev,
950950
if (ret)
951951
return -EIO;
952952
} else {
953-
gpio_set_value(chip->ldac_pin, 0);
954-
gpio_set_value(chip->ldac_pin, 1);
953+
gpiod_set_value(chip->ldac_pin, 0);
954+
gpiod_set_value(chip->ldac_pin, 1);
955955
}
956956

957957
return len;
@@ -2122,7 +2122,13 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus,
21222122
else
21232123
return -ENODEV;
21242124

2125-
chip->ldac_pin = adt7316_platform_data[1];
2125+
chip->ldac_pin = devm_gpiod_get_optional(dev, "ldac", GPIOD_OUT_LOW);
2126+
if (IS_ERR(chip->ldac_pin)) {
2127+
ret = PTR_ERR(chip->ldac_pin);
2128+
dev_err(dev, "Failed to request ldac GPIO: %d\n", ret);
2129+
return ret;
2130+
}
2131+
21262132
if (chip->ldac_pin) {
21272133
chip->config3 |= ADT7316_DA_EN_VIA_DAC_LDCA;
21282134
if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)

0 commit comments

Comments
 (0)