Commit 52555a5d authored by Dragos Bogdan's avatar Dragos Bogdan Committed by Jonathan Cameron

staging:iio:ad7780: Switch to the gpio descriptor interface

Use the gpiod interface for the powerdown_gpio instead of the deprecated
old non-descriptor interface.

The powerdown pin can be tied high, so the gpio is optional.
Remove the gpio_pdrst platform_data member since the new interface is
used.
Signed-off-by: default avatarDragos Bogdan <dragos.bogdan@analog.com>
Acked-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 7d173f26
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/iio/iio.h> #include <linux/iio/iio.h>
...@@ -42,7 +42,7 @@ struct ad7780_chip_info { ...@@ -42,7 +42,7 @@ struct ad7780_chip_info {
struct ad7780_state { struct ad7780_state {
const struct ad7780_chip_info *chip_info; const struct ad7780_chip_info *chip_info;
struct regulator *reg; struct regulator *reg;
int powerdown_gpio; struct gpio_desc *powerdown_gpio;
unsigned int gain; unsigned int gain;
u16 int_vref_mv; u16 int_vref_mv;
...@@ -77,8 +77,7 @@ static int ad7780_set_mode(struct ad_sigma_delta *sigma_delta, ...@@ -77,8 +77,7 @@ static int ad7780_set_mode(struct ad_sigma_delta *sigma_delta,
break; break;
} }
if (gpio_is_valid(st->powerdown_gpio)) gpiod_set_value(st->powerdown_gpio, val);
gpio_set_value(st->powerdown_gpio, val);
return 0; return 0;
} }
...@@ -205,18 +204,14 @@ static int ad7780_probe(struct spi_device *spi) ...@@ -205,18 +204,14 @@ static int ad7780_probe(struct spi_device *spi)
indio_dev->num_channels = 1; indio_dev->num_channels = 1;
indio_dev->info = &ad7780_info; indio_dev->info = &ad7780_info;
if (pdata && gpio_is_valid(pdata->gpio_pdrst)) { st->powerdown_gpio = devm_gpiod_get_optional(&spi->dev,
ret = devm_gpio_request_one(&spi->dev, "powerdown",
pdata->gpio_pdrst, GPIOD_OUT_LOW);
GPIOF_OUT_INIT_LOW, if (IS_ERR(st->powerdown_gpio)) {
"AD7780 /PDRST"); ret = PTR_ERR(st->powerdown_gpio);
if (ret) { dev_err(&spi->dev, "Failed to request powerdown GPIO: %d\n",
dev_err(&spi->dev, "failed to request GPIO PDRST\n"); ret);
goto error_disable_reg; goto error_disable_reg;
}
st->powerdown_gpio = pdata->gpio_pdrst;
} else {
st->powerdown_gpio = -1;
} }
ret = ad_sd_setup_buffer_and_trigger(indio_dev); ret = ad_sd_setup_buffer_and_trigger(indio_dev);
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
struct ad7780_platform_data { struct ad7780_platform_data {
u16 vref_mv; u16 vref_mv;
int gpio_pdrst;
}; };
#endif /* IIO_ADC_AD7780_H_ */ #endif /* IIO_ADC_AD7780_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment