[PATCH 3/6] iio: adc: ad7266: drop platform data support

From: Nuno Sá

Date: Wed Nov 25 2026 - 05:20:55 EST


There are no in-tree users of struct ad7266_platform_data. Without it,
the driver already falls back to a fixed address, differential mode
and the 0V - VREF input range.

Drop the platform data header and move the range and mode enums into
the driver. The code for the address GPIOs, the pseudo differential and
single-ended modes and the 0V - 2VREF range is kept so it can be
enabled again should someone need it and add firmware properties for
it.

Signed-off-by: Nuno Sá <nuno.sa@xxxxxxxxxx>
---
drivers/iio/adc/ad7266.c | 58 +++++++++++++++++++++++++-----------
include/linux/platform_data/ad7266.h | 50 -------------------------------
2 files changed, 41 insertions(+), 67 deletions(-)

diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
index 594a070c3745..2eba5d05d9b4 100644
--- a/drivers/iio/adc/ad7266.c
+++ b/drivers/iio/adc/ad7266.c
@@ -21,10 +21,35 @@
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>

-#include <linux/platform_data/ad7266.h>
-
#define AD7266_INTERNAL_REF_MV 2500

+/**
+ * enum ad7266_range - AD7266 reference voltage range
+ * @AD7266_RANGE_VREF: Device is configured for input range 0V - VREF
+ * (RANGE pin set to low)
+ * @AD7266_RANGE_2VREF: Device is configured for input range 0V - 2VREF
+ * (RANGE pin set to high)
+ */
+enum ad7266_range {
+ AD7266_RANGE_VREF,
+ AD7266_RANGE_2VREF,
+};
+
+/**
+ * enum ad7266_mode - AD7266 sample mode
+ * @AD7266_MODE_DIFF: Device is configured for full differential mode
+ * (SGL/DIFF pin set to low, AD0 pin set to low)
+ * @AD7266_MODE_PSEUDO_DIFF: Device is configured for pseudo differential mode
+ * (SGL/DIFF pin set to low, AD0 pin set to high)
+ * @AD7266_MODE_SINGLE_ENDED: Device is configured for single-ended mode
+ * (SGL/DIFF pin set to high)
+ */
+enum ad7266_mode {
+ AD7266_MODE_DIFF,
+ AD7266_MODE_PSEUDO_DIFF,
+ AD7266_MODE_SINGLE_ENDED,
+};
+
struct ad7266_state {
struct spi_device *spi;
unsigned long vref_mv;
@@ -381,7 +406,6 @@ static const char * const ad7266_gpio_labels[] = {

static int ad7266_probe(struct spi_device *spi)
{
- const struct ad7266_platform_data *pdata = dev_get_platdata(&spi->dev);
struct iio_dev *indio_dev;
struct ad7266_state *st;
unsigned int i;
@@ -399,24 +423,24 @@ static int ad7266_probe(struct spi_device *spi)

st->vref_mv = ret == -ENODEV ? AD7266_INTERNAL_REF_MV : ret / 1000;

- if (pdata) {
- st->fixed_addr = pdata->fixed_addr;
- st->mode = pdata->mode;
- st->range = pdata->range;
+ /*
+ * The address GPIOs, the other sample modes and the 0V - 2VREF range
+ * could only be selected through platform data, which had no users.
+ * Keep the support around in case someone needs it and adds firmware
+ * properties for it.
+ */
+ st->fixed_addr = true;
+ st->range = AD7266_RANGE_VREF;
+ st->mode = AD7266_MODE_DIFF;

- if (!st->fixed_addr) {
- for (i = 0; i < ARRAY_SIZE(st->gpios); ++i) {
- st->gpios[i] = devm_gpiod_get(&spi->dev,
+ if (!st->fixed_addr) {
+ for (i = 0; i < ARRAY_SIZE(st->gpios); ++i) {
+ st->gpios[i] = devm_gpiod_get(&spi->dev,
ad7266_gpio_labels[i],
GPIOD_OUT_LOW);
- if (IS_ERR(st->gpios[i]))
- return PTR_ERR(st->gpios[i]);
- }
+ if (IS_ERR(st->gpios[i]))
+ return PTR_ERR(st->gpios[i]);
}
- } else {
- st->fixed_addr = true;
- st->range = AD7266_RANGE_VREF;
- st->mode = AD7266_MODE_DIFF;
}

st->spi = spi;
diff --git a/include/linux/platform_data/ad7266.h b/include/linux/platform_data/ad7266.h
deleted file mode 100644
index f0652567afba..000000000000
--- a/include/linux/platform_data/ad7266.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * AD7266/65 SPI ADC driver
- *
- * Copyright 2012 Analog Devices Inc.
- */
-
-#ifndef __IIO_ADC_AD7266_H__
-#define __IIO_ADC_AD7266_H__
-
-/**
- * enum ad7266_range - AD7266 reference voltage range
- * @AD7266_RANGE_VREF: Device is configured for input range 0V - VREF
- * (RANGE pin set to low)
- * @AD7266_RANGE_2VREF: Device is configured for input range 0V - 2VREF
- * (RANGE pin set to high)
- */
-enum ad7266_range {
- AD7266_RANGE_VREF,
- AD7266_RANGE_2VREF,
-};
-
-/**
- * enum ad7266_mode - AD7266 sample mode
- * @AD7266_MODE_DIFF: Device is configured for full differential mode
- * (SGL/DIFF pin set to low, AD0 pin set to low)
- * @AD7266_MODE_PSEUDO_DIFF: Device is configured for pseudo differential mode
- * (SGL/DIFF pin set to low, AD0 pin set to high)
- * @AD7266_MODE_SINGLE_ENDED: Device is configured for single-ended mode
- * (SGL/DIFF pin set to high)
- */
-enum ad7266_mode {
- AD7266_MODE_DIFF,
- AD7266_MODE_PSEUDO_DIFF,
- AD7266_MODE_SINGLE_ENDED,
-};
-
-/**
- * struct ad7266_platform_data - Platform data for the AD7266 driver
- * @range: Reference voltage range the device is configured for
- * @mode: Sample mode the device is configured for
- * @fixed_addr: Whether the address pins are hard-wired
- */
-struct ad7266_platform_data {
- enum ad7266_range range;
- enum ad7266_mode mode;
- bool fixed_addr;
-};
-
-#endif

--
2.56.0