* [PATCH 4/7] Staging: iio: adt7316: Use device tree data to set ldac_pin
@ 2018-11-16 22:57 Shreeya Patel
2018-11-17 17:07 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Shreeya Patel @ 2018-11-16 22:57 UTC (permalink / raw)
To: lars, Michael.Hennerich, jic23, knaack.h, pmeerw, gregkh,
linux-iio, devel, linux-kernel
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>
---
drivers/staging/iio/addac/adt7316.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c
index 3f22d1088713..deb2f7b40f60 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;
@@ -2120,7 +2120,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, "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)
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 4/7] Staging: iio: adt7316: Use device tree data to set ldac_pin
2018-11-16 22:57 [PATCH 4/7] Staging: iio: adt7316: Use device tree data to set ldac_pin Shreeya Patel
@ 2018-11-17 17:07 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2018-11-17 17:07 UTC (permalink / raw)
To: Shreeya Patel
Cc: lars, Michael.Hennerich, knaack.h, pmeerw, gregkh, linux-iio,
devel, linux-kernel
On Sat, 17 Nov 2018 04:27:32 +0530
Shreeya Patel <shreeya.patel23498@gmail.com> wrote:
> 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>
Looks good to me. I'll pick this up once patch 3 is sorted.
Thanks,
Jonathan
> ---
> drivers/staging/iio/addac/adt7316.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c
> index 3f22d1088713..deb2f7b40f60 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;
> @@ -2120,7 +2120,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, "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)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-17 17:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-16 22:57 [PATCH 4/7] Staging: iio: adt7316: Use device tree data to set ldac_pin Shreeya Patel
2018-11-17 17:07 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).