summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodrigo Alencar <rodrigo.alencar@analog.com>2026-02-16 20:10:51 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2026-02-24 00:00:58 +0300
commitee4f8c56e46abd4bfeab1cee96cd391c0b7a3e4a (patch)
tree67d5cf6a09a190e38f06847bf7334f028944a359
parent5fdb9c833293c6c341f58dc8109a6fdd2556a034 (diff)
downloadlinux-ee4f8c56e46abd4bfeab1cee96cd391c0b7a3e4a.tar.xz
iio: amplifiers: ad8366: replace reset-gpio with reset controller
Remove reset_gpio from the device state struct and use the reset_control interface instead, using a local variable, as it is not being used anywhere else. The reset controller init is moved out from the switch case and optionally initialized for every device variant. Although not all devices have a reset pin the code does not need to change if it is not wired. Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r--drivers/iio/amplifiers/ad8366.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index e8c80551d524..8b3d6825423e 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -23,6 +23,7 @@
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/regulator/consumer.h>
+#include <linux/reset.h>
#include <linux/spi/spi.h>
#include <linux/types.h>
@@ -44,7 +45,6 @@ struct ad8366_info {
struct ad8366_state {
struct spi_device *spi;
struct mutex lock; /* protect sensor state */
- struct gpio_desc *reset_gpio;
unsigned char ch[2];
enum ad8366_type type;
const struct ad8366_info *info;
@@ -248,6 +248,7 @@ static const struct iio_chan_spec ada4961_channels[] = {
static int ad8366_probe(struct spi_device *spi)
{
struct device *dev = &spi->dev;
+ struct reset_control *rstc;
struct iio_dev *indio_dev;
struct ad8366_state *st;
int ret;
@@ -278,11 +279,6 @@ static int ad8366_probe(struct spi_device *spi)
case ID_ADL5240:
case ID_HMC792:
case ID_HMC1119:
- st->reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIGH);
- if (IS_ERR(st->reset_gpio))
- return dev_err_probe(dev, PTR_ERR(st->reset_gpio),
- "Failed to get reset gpio\n");
-
indio_dev->channels = ada4961_channels;
indio_dev->num_channels = ARRAY_SIZE(ada4961_channels);
break;
@@ -290,6 +286,11 @@ static int ad8366_probe(struct spi_device *spi)
return dev_err_probe(dev, -EINVAL, "Invalid device ID\n");
}
+ rstc = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL);
+ if (IS_ERR(rstc))
+ return dev_err_probe(dev, PTR_ERR(rstc),
+ "Failed to get reset controller\n");
+
st->info = &ad8366_infos[st->type];
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->info = &ad8366_info;