[PATCH 2/6] iio: adc: ad7887: drop platform data support
From: Nuno Sá
Date: Wed Nov 25 2026 - 05:21:16 EST
There are no in-tree users of struct ad7887_platform_data, and the
driver works fine without it. Its only knob, en_dual, selects dual
channel mode, where the AIN1/VREF pin is used as a second input.
Drop the platform data header and default to single channel mode, which
is what the driver does when no platform data is given. The dual
channel code is kept so it can be enabled again should someone need it
and add a firmware property for it.
Signed-off-by: Nuno Sá <nuno.sa@xxxxxxxxxx>
---
As stated in the cover, I'm glad to drop dead code if no one sees value
in keeping it for possible future changes (which are unlikely tbh).
---
drivers/iio/adc/ad7887.c | 13 ++++++++-----
include/linux/platform_data/ad7887.h | 21 ---------------------
2 files changed, 8 insertions(+), 26 deletions(-)
diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c
index 980e6a303047..32097b387d53 100644
--- a/drivers/iio/adc/ad7887.c
+++ b/drivers/iio/adc/ad7887.c
@@ -25,8 +25,6 @@
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>
-#include <linux/platform_data/ad7887.h>
-
#define AD7887_REF_DIS BIT(5) /* on-chip reference disable */
#define AD7887_DUAL BIT(4) /* dual-channel mode */
#define AD7887_CH_AIN1 BIT(3) /* convert on channel 1, DUAL=1 */
@@ -229,7 +227,12 @@ static void ad7887_reg_disable(void *data)
static int ad7887_probe(struct spi_device *spi)
{
- const struct ad7887_platform_data *pdata = dev_get_platdata(&spi->dev);
+ /*
+ * Dual channel mode could only be enabled through platform data, which
+ * had no users. Keep the support around in case someone needs it and
+ * adds a firmware property for it.
+ */
+ bool en_dual = false;
struct ad7887_state *st;
struct iio_dev *indio_dev;
uint8_t mode;
@@ -273,7 +276,7 @@ static int ad7887_probe(struct spi_device *spi)
mode = AD7887_PM_MODE4;
if (st->reg)
mode |= AD7887_REF_DIS;
- if (pdata && pdata->en_dual)
+ if (en_dual)
mode |= AD7887_DUAL;
st->tx_cmd_buf[0] = AD7887_CH_AIN0 | mode;
@@ -285,7 +288,7 @@ static int ad7887_probe(struct spi_device *spi)
spi_message_init(&st->msg[AD7887_CH0]);
spi_message_add_tail(&st->xfer[0], &st->msg[AD7887_CH0]);
- if (pdata && pdata->en_dual) {
+ if (en_dual) {
st->tx_cmd_buf[2] = AD7887_CH_AIN1 | mode;
st->xfer[1].rx_buf = &st->data[0];
diff --git a/include/linux/platform_data/ad7887.h b/include/linux/platform_data/ad7887.h
deleted file mode 100644
index 9b4dca6ae70b..000000000000
--- a/include/linux/platform_data/ad7887.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * AD7887 SPI ADC driver
- *
- * Copyright 2010 Analog Devices Inc.
- */
-#ifndef IIO_ADC_AD7887_H_
-#define IIO_ADC_AD7887_H_
-
-/**
- * struct ad7887_platform_data - AD7887 ADC driver platform data
- * @en_dual: Whether to use dual channel mode. If set to true AIN1 becomes the
- * second input channel, and Vref is internally connected to Vdd. If set to
- * false the device is used in single channel mode and AIN1/Vref is used as
- * VREF input.
- */
-struct ad7887_platform_data {
- bool en_dual;
-};
-
-#endif /* IIO_ADC_AD7887_H_ */
--
2.56.0