The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2 0/3] iio: Use named initializers for device_id structures
@ 2026-06-30 15:35 Uwe Kleine-König (The Capable Hub)
  2026-06-30 15:35 ` [PATCH v2 1/3] iio: adc: ti-tsc2046: Simplify device handling Uwe Kleine-König (The Capable Hub)
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-06-30 15:35 UTC (permalink / raw)
  To: Oleksij Rempel, Jonathan Cameron, Nuno Sá, Michael Hennerich,
	Greg Kroah-Hartman
  Cc: kernel, David Lechner, Andy Shevchenko, linux-iio, linux-kernel,
	linux, linux-staging

Hello,

v1 of this series can be found at
https://lore.kernel.org/linux-iio/cover.1781883685.git.u.kleine-koenig@baylibre.com
.

Jonathan already applied most of the v1 series, so here come only the
remaining bits with the following changes:

 - Squash the ti-tsc2046 changes together and simplify some more 
 - Apply the same simplification to the adis16550 driver. Jonathan
   asked the ADI people if they have a driver extention in the queue to
   actually make use of the device abstraction that is thrown away here.
   There was no reply yet, so I thought I'll implement this
   simplifictions such that it's clear what we're discussing.

Patch 3 was already part of v1 and Jonathan claimed to have applied it,
but it's not in his testing branch, so I included it here again.


Uwe Kleine-König (The Capable Hub) (3):
  iio: adc: ti-tsc2046: Simplify device handling
  iio: imu: adis16550: Simplify device abstraction
  staging: iio: Initialize spi_device_id arrays using member names

 drivers/iio/adc/ti-tsc2046.c           | 25 ++------
 drivers/iio/imu/adis16550.c            | 89 ++++++++------------------
 drivers/staging/iio/adc/ad7816.c       |  6 +-
 drivers/staging/iio/frequency/ad9834.c |  8 +--
 4 files changed, 37 insertions(+), 91 deletions(-)


base-commit: 76b8de6371463f29189d4df52f464c3fd6f3328e
-- 
2.47.3


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/3] iio: adc: ti-tsc2046: Simplify device handling
  2026-06-30 15:35 [PATCH v2 0/3] iio: Use named initializers for device_id structures Uwe Kleine-König (The Capable Hub)
@ 2026-06-30 15:35 ` Uwe Kleine-König (The Capable Hub)
  2026-06-30 23:02   ` Jonathan Cameron
  2026-07-01  4:41   ` Oleksij Rempel
  2026-06-30 15:35 ` [PATCH v2 2/3] iio: imu: adis16550: Simplify device abstraction Uwe Kleine-König (The Capable Hub)
  2026-06-30 15:35 ` [PATCH v2 3/3] staging: iio: Initialize spi_device_id arrays using member names Uwe Kleine-König (The Capable Hub)
  2 siblings, 2 replies; 9+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-06-30 15:35 UTC (permalink / raw)
  To: Oleksij Rempel, Jonathan Cameron
  Cc: kernel, David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
	linux-kernel

The driver was introduced in 2021 and since then only supports a single
chip variant. Simplify the driver by hard-coding the device properties
instead of using the id_table's abstraction for a single chip type.

Also drop the write-only struct member dcfg and the then unused struct
definition.

Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
 drivers/iio/adc/ti-tsc2046.c | 25 ++++---------------------
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/iio/adc/ti-tsc2046.c b/drivers/iio/adc/ti-tsc2046.c
index aba4b10a17ac..125f6d7e2d84 100644
--- a/drivers/iio/adc/ti-tsc2046.c
+++ b/drivers/iio/adc/ti-tsc2046.c
@@ -121,11 +121,6 @@ struct tsc2046_adc_group_layout {
 	unsigned int skip;
 };
 
-struct tsc2046_adc_dcfg {
-	const struct iio_chan_spec *channels;
-	unsigned int num_channels;
-};
-
 struct tsc2046_adc_ch_cfg {
 	unsigned int settling_time_us;
 	unsigned int oversampling_ratio;
@@ -141,7 +136,6 @@ enum tsc2046_state {
 
 struct tsc2046_adc_priv {
 	struct spi_device *spi;
-	const struct tsc2046_adc_dcfg *dcfg;
 	bool internal_vref;
 
 	struct iio_trigger *trig;
@@ -214,11 +208,6 @@ const struct iio_chan_spec name ## _channels[] = { \
 
 static DECLARE_TI_TSC2046_8_CHANNELS(tsc2046_adc, 12);
 
-static const struct tsc2046_adc_dcfg tsc2046_adc_dcfg_tsc2046e = {
-	.channels = tsc2046_adc_channels,
-	.num_channels = ARRAY_SIZE(tsc2046_adc_channels),
-};
-
 /*
  * Convert time to a number of samples which can be transferred within this
  * time.
@@ -739,7 +728,6 @@ static void tsc2046_adc_parse_fwnode(struct tsc2046_adc_priv *priv)
 
 static int tsc2046_adc_probe(struct spi_device *spi)
 {
-	const struct tsc2046_adc_dcfg *dcfg;
 	struct device *dev = &spi->dev;
 	struct tsc2046_adc_priv *priv;
 	struct iio_dev *indio_dev;
@@ -752,10 +740,6 @@ static int tsc2046_adc_probe(struct spi_device *spi)
 		return -EINVAL;
 	}
 
-	dcfg = spi_get_device_match_data(spi);
-	if (!dcfg)
-		return -EINVAL;
-
 	spi->mode &= ~SPI_MODE_X_MASK;
 	spi->mode |= SPI_MODE_0;
 	ret = spi_setup(spi);
@@ -767,14 +751,13 @@ static int tsc2046_adc_probe(struct spi_device *spi)
 		return -ENOMEM;
 
 	priv = iio_priv(indio_dev);
-	priv->dcfg = dcfg;
 
 	priv->spi = spi;
 
 	indio_dev->name = TI_TSC2046_NAME;
 	indio_dev->modes = INDIO_DIRECT_MODE;
-	indio_dev->channels = dcfg->channels;
-	indio_dev->num_channels = dcfg->num_channels;
+	indio_dev->channels = tsc2046_adc_channels;
+	indio_dev->num_channels = ARRAY_SIZE(tsc2046_adc_channels);
 	indio_dev->info = &tsc2046_adc_info;
 
 	ret = devm_regulator_get_enable_read_voltage(dev, "vref");
@@ -829,13 +812,13 @@ static int tsc2046_adc_probe(struct spi_device *spi)
 }
 
 static const struct of_device_id ads7950_of_table[] = {
-	{ .compatible = "ti,tsc2046e-adc", .data = &tsc2046_adc_dcfg_tsc2046e },
+	{ .compatible = "ti,tsc2046e-adc" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ads7950_of_table);
 
 static const struct spi_device_id tsc2046_adc_spi_ids[] = {
-	{ "tsc2046e-adc", (unsigned long)&tsc2046_adc_dcfg_tsc2046e },
+	{ .name = "tsc2046e-adc" },
 	{ }
 };
 MODULE_DEVICE_TABLE(spi, tsc2046_adc_spi_ids);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/3] iio: imu: adis16550: Simplify device abstraction
  2026-06-30 15:35 [PATCH v2 0/3] iio: Use named initializers for device_id structures Uwe Kleine-König (The Capable Hub)
  2026-06-30 15:35 ` [PATCH v2 1/3] iio: adc: ti-tsc2046: Simplify device handling Uwe Kleine-König (The Capable Hub)
@ 2026-06-30 15:35 ` Uwe Kleine-König (The Capable Hub)
  2026-07-01 15:14   ` Nuno Sá
  2026-06-30 15:35 ` [PATCH v2 3/3] staging: iio: Initialize spi_device_id arrays using member names Uwe Kleine-König (The Capable Hub)
  2 siblings, 1 reply; 9+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-06-30 15:35 UTC (permalink / raw)
  To: Nuno Sá, Michael Hennerich, Jonathan Cameron
  Cc: David Lechner, Andy Shevchenko, linux, linux-iio, linux-kernel

The driver supports a single chip variant only. Simplify the driver by
hard-coding the device properties instead of using the id_table's
abstraction for a single chip type and a lookup in a table with only one
entry.

Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
 drivers/iio/imu/adis16550.c | 89 +++++++++++--------------------------
 1 file changed, 26 insertions(+), 63 deletions(-)

diff --git a/drivers/iio/imu/adis16550.c b/drivers/iio/imu/adis16550.c
index 75679612052f..fe0034964408 100644
--- a/drivers/iio/imu/adis16550.c
+++ b/drivers/iio/imu/adis16550.c
@@ -89,25 +89,7 @@ struct adis16550_sync {
 	u16 max_rate;
 };
 
-struct adis16550_chip_info {
-	const struct iio_chan_spec *channels;
-	const struct adis16550_sync *sync_mode;
-	char *name;
-	u32 num_channels;
-	u32 gyro_max_val;
-	u32 gyro_max_scale;
-	u32 accel_max_val;
-	u32 accel_max_scale;
-	u32 temp_scale;
-	u32 deltang_max_val;
-	u32 deltvel_max_val;
-	u32 int_clk;
-	u16 max_dec;
-	u16 num_sync;
-};
-
 struct adis16550 {
-	const struct adis16550_chip_info *info;
 	struct adis adis;
 	unsigned long clk_freq_hz;
 	u32 sync_mode;
@@ -450,8 +432,8 @@ static int adis16550_set_freq_hz(struct adis16550 *st, u32 freq_hz)
 	 * The optimal sample rate for the supported IMUs is between
 	 * int_clk - 1000 and int_clk + 500.
 	 */
-	u32 max_sample_rate = st->info->int_clk * 1000 + 500000;
-	u32 min_sample_rate = st->info->int_clk * 1000 - 1000000;
+	u32 max_sample_rate = 4000 * 1000 + 500000;
+	u32 min_sample_rate = 4000 * 1000 - 1000000;
 
 	if (!freq_hz)
 		return -EINVAL;
@@ -484,7 +466,7 @@ static int adis16550_set_freq_hz(struct adis16550 *st, u32 freq_hz)
 	if (dec)
 		dec--;
 
-	dec = min(dec, st->info->max_dec);
+	dec = min(dec, 4095);
 
 	return __adis_write_reg_16(&st->adis, ADIS16550_REG_DEC_RATE, dec);
 }
@@ -592,30 +574,30 @@ static int adis16550_read_raw(struct iio_dev *indio_dev,
 	case IIO_CHAN_INFO_SCALE:
 		switch (chan->type) {
 		case IIO_ANGL_VEL:
-			*val = st->info->gyro_max_val;
-			*val2 = st->info->gyro_max_scale;
+			*val = 1;
+			*val2 = IIO_RAD_TO_DEGREE(80 << 16);
 			return IIO_VAL_FRACTIONAL;
 		case IIO_ACCEL:
-			*val = st->info->accel_max_val;
-			*val2 = st->info->accel_max_scale;
+			*val = 1;
+			*val2 = IIO_M_S_2_TO_G(102400000);
 			return IIO_VAL_FRACTIONAL;
 		case IIO_TEMP:
-			*val = st->info->temp_scale;
+			*val = 4;
 			return IIO_VAL_INT;
 		case IIO_DELTA_ANGL:
-			*val = st->info->deltang_max_val;
+			*val = IIO_DEGREE_TO_RAD(720);
 			*val2 = 31;
 			return IIO_VAL_FRACTIONAL_LOG2;
 		case IIO_DELTA_VELOCITY:
-			*val = st->info->deltvel_max_val;
+			*val = 125;
 			*val2 = 31;
 			return IIO_VAL_FRACTIONAL_LOG2;
 		default:
 			return -EINVAL;
 		}
 	case IIO_CHAN_INFO_OFFSET:
-		/* temperature centered at 25°C */
-		*val = DIV_ROUND_CLOSEST(25000, st->info->temp_scale);
+		/* temperature centered at 25°C divided by temp scale */
+		*val = 25000 / 4;
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_CALIBBIAS:
 		ret = adis_read_reg_32(&st->adis,
@@ -793,23 +775,6 @@ static const struct adis16550_sync adis16550_sync_modes[] = {
 	{ ADIS16550_SYNC_MODE_SCALED, 1, 128 },
 };
 
-static const struct adis16550_chip_info adis16550_chip_info = {
-	.num_channels = ARRAY_SIZE(adis16550_channels),
-	.channels = adis16550_channels,
-	.name = "adis16550",
-	.gyro_max_val = 1,
-	.gyro_max_scale = IIO_RAD_TO_DEGREE(80 << 16),
-	.accel_max_val = 1,
-	.accel_max_scale = IIO_M_S_2_TO_G(102400000),
-	.temp_scale = 4,
-	.deltang_max_val = IIO_DEGREE_TO_RAD(720),
-	.deltvel_max_val = 125,
-	.int_clk = 4000,
-	.max_dec = 4095,
-	.sync_mode = adis16550_sync_modes,
-	.num_sync = ARRAY_SIZE(adis16550_sync_modes),
-};
-
 static u32 adis16550_validate_crc(__be32 *buffer, const u8 n_elem)
 {
 	int i;
@@ -918,21 +883,21 @@ static int adis16550_config_sync(struct adis16550 *st)
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 	if (!clk) {
-		st->clk_freq_hz = st->info->int_clk * 1000;
+		st->clk_freq_hz = 4000000;
 		return 0;
 	}
 
 	st->clk_freq_hz = clk_get_rate(clk);
 
-	for (i = 0; i < st->info->num_sync; i++) {
-		if (st->clk_freq_hz >= st->info->sync_mode[i].min_rate &&
-		    st->clk_freq_hz <= st->info->sync_mode[i].max_rate) {
-			sync_mode_data = &st->info->sync_mode[i];
+	for (i = 0; i < ARRAY_SIZE(adis16550_sync_modes); i++) {
+		if (st->clk_freq_hz >= adis16550_sync_modes[i].min_rate &&
+		    st->clk_freq_hz <= adis16550_sync_modes[i].max_rate) {
+			sync_mode_data = &adis16550_sync_modes[i];
 			break;
 		}
 	}
 
-	if (i == st->info->num_sync)
+	if (i == ARRAY_SIZE(adis16550_sync_modes))
 		return dev_err_probe(dev, -EINVAL, "Clk rate: %lu not in a valid range",
 				     st->clk_freq_hz);
 
@@ -943,7 +908,7 @@ static int adis16550_config_sync(struct adis16550 *st)
 		 * of [3000 4500].
 		 */
 
-		sync_scale = DIV_ROUND_CLOSEST(st->info->int_clk, st->clk_freq_hz);
+		sync_scale = DIV_ROUND_CLOSEST(4000, st->clk_freq_hz);
 
 		if (3000 > sync_scale || 4500 < sync_scale)
 			return dev_err_probe(dev, -EINVAL,
@@ -955,7 +920,7 @@ static int adis16550_config_sync(struct adis16550 *st)
 		if (ret)
 			return ret;
 
-		st->clk_freq_hz = st->info->int_clk;
+		st->clk_freq_hz = 4000;
 	}
 
 	st->clk_freq_hz *= 1000;
@@ -1064,13 +1029,11 @@ static int adis16550_probe(struct spi_device *spi)
 		return -ENOMEM;
 
 	st = iio_priv(indio_dev);
-	st->info = spi_get_device_match_data(spi);
-	if (!st->info)
-		return -EINVAL;
+
 	adis = &st->adis;
-	indio_dev->name = st->info->name;
-	indio_dev->channels = st->info->channels;
-	indio_dev->num_channels = st->info->num_channels;
+	indio_dev->name = "adis16550";
+	indio_dev->channels = adis16550_channels;
+	indio_dev->num_channels = ARRAY_SIZE(adis16550_channels);
 	indio_dev->available_scan_masks = adis16550_channel_masks;
 	indio_dev->info = &adis16550_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
@@ -1117,13 +1080,13 @@ static int adis16550_probe(struct spi_device *spi)
 }
 
 static const struct spi_device_id adis16550_id[] = {
-	{ "adis16550",  (kernel_ulong_t)&adis16550_chip_info},
+	{ .name = "adis16550" },
 	{ }
 };
 MODULE_DEVICE_TABLE(spi, adis16550_id);
 
 static const struct of_device_id adis16550_of_match[] = {
-	{ .compatible = "adi,adis16550", .data = &adis16550_chip_info },
+	{ .compatible = "adi,adis16550" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, adis16550_of_match);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 3/3] staging: iio: Initialize spi_device_id arrays using member names
  2026-06-30 15:35 [PATCH v2 0/3] iio: Use named initializers for device_id structures Uwe Kleine-König (The Capable Hub)
  2026-06-30 15:35 ` [PATCH v2 1/3] iio: adc: ti-tsc2046: Simplify device handling Uwe Kleine-König (The Capable Hub)
  2026-06-30 15:35 ` [PATCH v2 2/3] iio: imu: adis16550: Simplify device abstraction Uwe Kleine-König (The Capable Hub)
@ 2026-06-30 15:35 ` Uwe Kleine-König (The Capable Hub)
  2026-06-30 22:59   ` Jonathan Cameron
  2 siblings, 1 reply; 9+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-06-30 15:35 UTC (permalink / raw)
  To: Nuno Sá, Michael Hennerich, Jonathan Cameron,
	Greg Kroah-Hartman
  Cc: David Lechner, Andy Shevchenko, linux, linux-iio, linux-staging,
	linux-kernel

While being less compact, using named initializers allows to more easily
see which members of the structs are assigned which value without having
to lookup the declaration of the struct. And it's also more robust
against changes to the struct definition.

The mentioned robustness is relevant for a planned change to struct
spi_device_id that replaces .driver_data by an anonymous union.

This patch doesn't modify the compiled arrays, only their representation
in source form benefits. The former was confirmed with x86 and arm64
builds.

Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/cac7a68e6a6adb1b58207640ab045e59eec86f53.1781883685.git.u.kleine-koenig@baylibre.com
---
 drivers/staging/iio/adc/ad7816.c       | 6 +++---
 drivers/staging/iio/frequency/ad9834.c | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
index 0e32a2295990..30644d2d7c54 100644
--- a/drivers/staging/iio/adc/ad7816.c
+++ b/drivers/staging/iio/adc/ad7816.c
@@ -426,9 +426,9 @@ static const struct of_device_id ad7816_of_match[] = {
 MODULE_DEVICE_TABLE(of, ad7816_of_match);
 
 static const struct spi_device_id ad7816_id[] = {
-	{ "ad7816", ID_AD7816 },
-	{ "ad7817", ID_AD7817 },
-	{ "ad7818", ID_AD7818 },
+	{ .name = "ad7816", .driver_data = ID_AD7816 },
+	{ .name = "ad7817", .driver_data = ID_AD7817 },
+	{ .name = "ad7818", .driver_data = ID_AD7818 },
 	{ }
 };
 
diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c
index 4359b358e0e5..f95c5365cd03 100644
--- a/drivers/staging/iio/frequency/ad9834.c
+++ b/drivers/staging/iio/frequency/ad9834.c
@@ -465,10 +465,10 @@ static int ad9834_probe(struct spi_device *spi)
 }
 
 static const struct spi_device_id ad9834_id[] = {
-	{"ad9833", ID_AD9833},
-	{"ad9834", ID_AD9834},
-	{"ad9837", ID_AD9837},
-	{"ad9838", ID_AD9838},
+	{ .name = "ad9833", .driver_data = ID_AD9833 },
+	{ .name = "ad9834", .driver_data = ID_AD9834 },
+	{ .name = "ad9837", .driver_data = ID_AD9837 },
+	{ .name = "ad9838", .driver_data = ID_AD9838 },
 	{ }
 };
 MODULE_DEVICE_TABLE(spi, ad9834_id);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 3/3] staging: iio: Initialize spi_device_id arrays using member names
  2026-06-30 15:35 ` [PATCH v2 3/3] staging: iio: Initialize spi_device_id arrays using member names Uwe Kleine-König (The Capable Hub)
@ 2026-06-30 22:59   ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2026-06-30 22:59 UTC (permalink / raw)
  To: Uwe Kleine-König (The Capable Hub)
  Cc: Nuno Sá, Michael Hennerich, Greg Kroah-Hartman,
	David Lechner, Andy Shevchenko, linux, linux-iio, linux-staging,
	linux-kernel

On Tue, 30 Jun 2026 17:35:36 +0200
Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> wrote:

> While being less compact, using named initializers allows to more easily
> see which members of the structs are assigned which value without having
> to lookup the declaration of the struct. And it's also more robust
> against changes to the struct definition.
> 
> The mentioned robustness is relevant for a planned change to struct
> spi_device_id that replaces .driver_data by an anonymous union.
> 
> This patch doesn't modify the compiled arrays, only their representation
> in source form benefits. The former was confirmed with x86 and arm64
> builds.
> 
> Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
> Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> Link: https://patch.msgid.link/cac7a68e6a6adb1b58207640ab045e59eec86f53.1781883685.git.u.kleine-koenig@baylibre.com
Given I messed up applying this in v1, picked up now.

Thanks for catching that miss!

Jonathan

> ---
>  drivers/staging/iio/adc/ad7816.c       | 6 +++---
>  drivers/staging/iio/frequency/ad9834.c | 8 ++++----
>  2 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
> index 0e32a2295990..30644d2d7c54 100644
> --- a/drivers/staging/iio/adc/ad7816.c
> +++ b/drivers/staging/iio/adc/ad7816.c
> @@ -426,9 +426,9 @@ static const struct of_device_id ad7816_of_match[] = {
>  MODULE_DEVICE_TABLE(of, ad7816_of_match);
>  
>  static const struct spi_device_id ad7816_id[] = {
> -	{ "ad7816", ID_AD7816 },
> -	{ "ad7817", ID_AD7817 },
> -	{ "ad7818", ID_AD7818 },
> +	{ .name = "ad7816", .driver_data = ID_AD7816 },
> +	{ .name = "ad7817", .driver_data = ID_AD7817 },
> +	{ .name = "ad7818", .driver_data = ID_AD7818 },
>  	{ }
>  };
>  
> diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c
> index 4359b358e0e5..f95c5365cd03 100644
> --- a/drivers/staging/iio/frequency/ad9834.c
> +++ b/drivers/staging/iio/frequency/ad9834.c
> @@ -465,10 +465,10 @@ static int ad9834_probe(struct spi_device *spi)
>  }
>  
>  static const struct spi_device_id ad9834_id[] = {
> -	{"ad9833", ID_AD9833},
> -	{"ad9834", ID_AD9834},
> -	{"ad9837", ID_AD9837},
> -	{"ad9838", ID_AD9838},
> +	{ .name = "ad9833", .driver_data = ID_AD9833 },
> +	{ .name = "ad9834", .driver_data = ID_AD9834 },
> +	{ .name = "ad9837", .driver_data = ID_AD9837 },
> +	{ .name = "ad9838", .driver_data = ID_AD9838 },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(spi, ad9834_id);


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/3] iio: adc: ti-tsc2046: Simplify device handling
  2026-06-30 15:35 ` [PATCH v2 1/3] iio: adc: ti-tsc2046: Simplify device handling Uwe Kleine-König (The Capable Hub)
@ 2026-06-30 23:02   ` Jonathan Cameron
  2026-07-01  4:41   ` Oleksij Rempel
  1 sibling, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2026-06-30 23:02 UTC (permalink / raw)
  To: Uwe Kleine-König (The Capable Hub)
  Cc: Oleksij Rempel, kernel, David Lechner, Nuno Sá,
	Andy Shevchenko, linux-iio, linux-kernel

On Tue, 30 Jun 2026 17:35:34 +0200
Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> wrote:

> The driver was introduced in 2021 and since then only supports a single
> chip variant. Simplify the driver by hard-coding the device properties
> instead of using the id_table's abstraction for a single chip type.
> 
> Also drop the write-only struct member dcfg and the then unused struct
> definition.
> 
> Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
Addresses feedback on v1, so all good,

Applied to the testing branch of iio.git.

I'll sit on patch 2 for a little while to see if it stirs up discussion!

Jonathan

> ---
>  drivers/iio/adc/ti-tsc2046.c | 25 ++++---------------------
>  1 file changed, 4 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/iio/adc/ti-tsc2046.c b/drivers/iio/adc/ti-tsc2046.c
> index aba4b10a17ac..125f6d7e2d84 100644
> --- a/drivers/iio/adc/ti-tsc2046.c
> +++ b/drivers/iio/adc/ti-tsc2046.c
> @@ -121,11 +121,6 @@ struct tsc2046_adc_group_layout {
>  	unsigned int skip;
>  };
>  
> -struct tsc2046_adc_dcfg {
> -	const struct iio_chan_spec *channels;
> -	unsigned int num_channels;
> -};
> -
>  struct tsc2046_adc_ch_cfg {
>  	unsigned int settling_time_us;
>  	unsigned int oversampling_ratio;
> @@ -141,7 +136,6 @@ enum tsc2046_state {
>  
>  struct tsc2046_adc_priv {
>  	struct spi_device *spi;
> -	const struct tsc2046_adc_dcfg *dcfg;
>  	bool internal_vref;
>  
>  	struct iio_trigger *trig;
> @@ -214,11 +208,6 @@ const struct iio_chan_spec name ## _channels[] = { \
>  
>  static DECLARE_TI_TSC2046_8_CHANNELS(tsc2046_adc, 12);
>  
> -static const struct tsc2046_adc_dcfg tsc2046_adc_dcfg_tsc2046e = {
> -	.channels = tsc2046_adc_channels,
> -	.num_channels = ARRAY_SIZE(tsc2046_adc_channels),
> -};
> -
>  /*
>   * Convert time to a number of samples which can be transferred within this
>   * time.
> @@ -739,7 +728,6 @@ static void tsc2046_adc_parse_fwnode(struct tsc2046_adc_priv *priv)
>  
>  static int tsc2046_adc_probe(struct spi_device *spi)
>  {
> -	const struct tsc2046_adc_dcfg *dcfg;
>  	struct device *dev = &spi->dev;
>  	struct tsc2046_adc_priv *priv;
>  	struct iio_dev *indio_dev;
> @@ -752,10 +740,6 @@ static int tsc2046_adc_probe(struct spi_device *spi)
>  		return -EINVAL;
>  	}
>  
> -	dcfg = spi_get_device_match_data(spi);
> -	if (!dcfg)
> -		return -EINVAL;
> -
>  	spi->mode &= ~SPI_MODE_X_MASK;
>  	spi->mode |= SPI_MODE_0;
>  	ret = spi_setup(spi);
> @@ -767,14 +751,13 @@ static int tsc2046_adc_probe(struct spi_device *spi)
>  		return -ENOMEM;
>  
>  	priv = iio_priv(indio_dev);
> -	priv->dcfg = dcfg;
>  
>  	priv->spi = spi;
>  
>  	indio_dev->name = TI_TSC2046_NAME;
>  	indio_dev->modes = INDIO_DIRECT_MODE;
> -	indio_dev->channels = dcfg->channels;
> -	indio_dev->num_channels = dcfg->num_channels;
> +	indio_dev->channels = tsc2046_adc_channels;
> +	indio_dev->num_channels = ARRAY_SIZE(tsc2046_adc_channels);
>  	indio_dev->info = &tsc2046_adc_info;
>  
>  	ret = devm_regulator_get_enable_read_voltage(dev, "vref");
> @@ -829,13 +812,13 @@ static int tsc2046_adc_probe(struct spi_device *spi)
>  }
>  
>  static const struct of_device_id ads7950_of_table[] = {
> -	{ .compatible = "ti,tsc2046e-adc", .data = &tsc2046_adc_dcfg_tsc2046e },
> +	{ .compatible = "ti,tsc2046e-adc" },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(of, ads7950_of_table);
>  
>  static const struct spi_device_id tsc2046_adc_spi_ids[] = {
> -	{ "tsc2046e-adc", (unsigned long)&tsc2046_adc_dcfg_tsc2046e },
> +	{ .name = "tsc2046e-adc" },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(spi, tsc2046_adc_spi_ids);


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/3] iio: adc: ti-tsc2046: Simplify device handling
  2026-06-30 15:35 ` [PATCH v2 1/3] iio: adc: ti-tsc2046: Simplify device handling Uwe Kleine-König (The Capable Hub)
  2026-06-30 23:02   ` Jonathan Cameron
@ 2026-07-01  4:41   ` Oleksij Rempel
  1 sibling, 0 replies; 9+ messages in thread
From: Oleksij Rempel @ 2026-07-01  4:41 UTC (permalink / raw)
  To: Uwe Kleine-König (The Capable Hub)
  Cc: Jonathan Cameron, kernel, David Lechner, Nuno Sá,
	Andy Shevchenko, linux-iio, linux-kernel

On Tue, Jun 30, 2026 at 05:35:34PM +0200, Uwe Kleine-König (The Capable Hub) wrote:
> The driver was introduced in 2021 and since then only supports a single
> chip variant. Simplify the driver by hard-coding the device properties
> instead of using the id_table's abstraction for a single chip type.
> 
> Also drop the write-only struct member dcfg and the then unused struct
> definition.
> 
> Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>

LGTM - Thank you!

Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/3] iio: imu: adis16550: Simplify device abstraction
  2026-06-30 15:35 ` [PATCH v2 2/3] iio: imu: adis16550: Simplify device abstraction Uwe Kleine-König (The Capable Hub)
@ 2026-07-01 15:14   ` Nuno Sá
  2026-07-01 17:40     ` Jonathan Cameron
  0 siblings, 1 reply; 9+ messages in thread
From: Nuno Sá @ 2026-07-01 15:14 UTC (permalink / raw)
  To: Uwe Kleine-König (The Capable Hub)
  Cc: Nuno Sá, Michael Hennerich, Jonathan Cameron, David Lechner,
	Andy Shevchenko, linux, linux-iio, linux-kernel

On Tue, Jun 30, 2026 at 05:35:35PM +0200, Uwe Kleine-König (The Capable Hub) wrote:
> The driver supports a single chip variant only. Simplify the driver by
> hard-coding the device properties instead of using the id_table's
> abstraction for a single chip type and a lookup in a table with only one
> entry.
> 
> Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
> ---

LGTM

Reviewed-by: Nuno Sá <nuno.sa@analog.com>

>  drivers/iio/imu/adis16550.c | 89 +++++++++++--------------------------
>  1 file changed, 26 insertions(+), 63 deletions(-)
> 
> diff --git a/drivers/iio/imu/adis16550.c b/drivers/iio/imu/adis16550.c
> index 75679612052f..fe0034964408 100644
> --- a/drivers/iio/imu/adis16550.c
> +++ b/drivers/iio/imu/adis16550.c
> @@ -89,25 +89,7 @@ struct adis16550_sync {
>  	u16 max_rate;
>  };
>  
> -struct adis16550_chip_info {
> -	const struct iio_chan_spec *channels;
> -	const struct adis16550_sync *sync_mode;
> -	char *name;
> -	u32 num_channels;
> -	u32 gyro_max_val;
> -	u32 gyro_max_scale;
> -	u32 accel_max_val;
> -	u32 accel_max_scale;
> -	u32 temp_scale;
> -	u32 deltang_max_val;
> -	u32 deltvel_max_val;
> -	u32 int_clk;
> -	u16 max_dec;
> -	u16 num_sync;
> -};
> -
>  struct adis16550 {
> -	const struct adis16550_chip_info *info;
>  	struct adis adis;
>  	unsigned long clk_freq_hz;
>  	u32 sync_mode;
> @@ -450,8 +432,8 @@ static int adis16550_set_freq_hz(struct adis16550 *st, u32 freq_hz)
>  	 * The optimal sample rate for the supported IMUs is between
>  	 * int_clk - 1000 and int_clk + 500.
>  	 */
> -	u32 max_sample_rate = st->info->int_clk * 1000 + 500000;
> -	u32 min_sample_rate = st->info->int_clk * 1000 - 1000000;
> +	u32 max_sample_rate = 4000 * 1000 + 500000;
> +	u32 min_sample_rate = 4000 * 1000 - 1000000;
>  
>  	if (!freq_hz)
>  		return -EINVAL;
> @@ -484,7 +466,7 @@ static int adis16550_set_freq_hz(struct adis16550 *st, u32 freq_hz)
>  	if (dec)
>  		dec--;
>  
> -	dec = min(dec, st->info->max_dec);
> +	dec = min(dec, 4095);
>  
>  	return __adis_write_reg_16(&st->adis, ADIS16550_REG_DEC_RATE, dec);
>  }
> @@ -592,30 +574,30 @@ static int adis16550_read_raw(struct iio_dev *indio_dev,
>  	case IIO_CHAN_INFO_SCALE:
>  		switch (chan->type) {
>  		case IIO_ANGL_VEL:
> -			*val = st->info->gyro_max_val;
> -			*val2 = st->info->gyro_max_scale;
> +			*val = 1;
> +			*val2 = IIO_RAD_TO_DEGREE(80 << 16);
>  			return IIO_VAL_FRACTIONAL;
>  		case IIO_ACCEL:
> -			*val = st->info->accel_max_val;
> -			*val2 = st->info->accel_max_scale;
> +			*val = 1;
> +			*val2 = IIO_M_S_2_TO_G(102400000);
>  			return IIO_VAL_FRACTIONAL;
>  		case IIO_TEMP:
> -			*val = st->info->temp_scale;
> +			*val = 4;
>  			return IIO_VAL_INT;
>  		case IIO_DELTA_ANGL:
> -			*val = st->info->deltang_max_val;
> +			*val = IIO_DEGREE_TO_RAD(720);
>  			*val2 = 31;
>  			return IIO_VAL_FRACTIONAL_LOG2;
>  		case IIO_DELTA_VELOCITY:
> -			*val = st->info->deltvel_max_val;
> +			*val = 125;
>  			*val2 = 31;
>  			return IIO_VAL_FRACTIONAL_LOG2;
>  		default:
>  			return -EINVAL;
>  		}
>  	case IIO_CHAN_INFO_OFFSET:
> -		/* temperature centered at 25°C */
> -		*val = DIV_ROUND_CLOSEST(25000, st->info->temp_scale);
> +		/* temperature centered at 25°C divided by temp scale */
> +		*val = 25000 / 4;
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_CALIBBIAS:
>  		ret = adis_read_reg_32(&st->adis,
> @@ -793,23 +775,6 @@ static const struct adis16550_sync adis16550_sync_modes[] = {
>  	{ ADIS16550_SYNC_MODE_SCALED, 1, 128 },
>  };
>  
> -static const struct adis16550_chip_info adis16550_chip_info = {
> -	.num_channels = ARRAY_SIZE(adis16550_channels),
> -	.channels = adis16550_channels,
> -	.name = "adis16550",
> -	.gyro_max_val = 1,
> -	.gyro_max_scale = IIO_RAD_TO_DEGREE(80 << 16),
> -	.accel_max_val = 1,
> -	.accel_max_scale = IIO_M_S_2_TO_G(102400000),
> -	.temp_scale = 4,
> -	.deltang_max_val = IIO_DEGREE_TO_RAD(720),
> -	.deltvel_max_val = 125,
> -	.int_clk = 4000,
> -	.max_dec = 4095,
> -	.sync_mode = adis16550_sync_modes,
> -	.num_sync = ARRAY_SIZE(adis16550_sync_modes),
> -};
> -
>  static u32 adis16550_validate_crc(__be32 *buffer, const u8 n_elem)
>  {
>  	int i;
> @@ -918,21 +883,21 @@ static int adis16550_config_sync(struct adis16550 *st)
>  	if (IS_ERR(clk))
>  		return PTR_ERR(clk);
>  	if (!clk) {
> -		st->clk_freq_hz = st->info->int_clk * 1000;
> +		st->clk_freq_hz = 4000000;
>  		return 0;
>  	}
>  
>  	st->clk_freq_hz = clk_get_rate(clk);
>  
> -	for (i = 0; i < st->info->num_sync; i++) {
> -		if (st->clk_freq_hz >= st->info->sync_mode[i].min_rate &&
> -		    st->clk_freq_hz <= st->info->sync_mode[i].max_rate) {
> -			sync_mode_data = &st->info->sync_mode[i];
> +	for (i = 0; i < ARRAY_SIZE(adis16550_sync_modes); i++) {
> +		if (st->clk_freq_hz >= adis16550_sync_modes[i].min_rate &&
> +		    st->clk_freq_hz <= adis16550_sync_modes[i].max_rate) {
> +			sync_mode_data = &adis16550_sync_modes[i];
>  			break;
>  		}
>  	}
>  
> -	if (i == st->info->num_sync)
> +	if (i == ARRAY_SIZE(adis16550_sync_modes))
>  		return dev_err_probe(dev, -EINVAL, "Clk rate: %lu not in a valid range",
>  				     st->clk_freq_hz);
>  
> @@ -943,7 +908,7 @@ static int adis16550_config_sync(struct adis16550 *st)
>  		 * of [3000 4500].
>  		 */
>  
> -		sync_scale = DIV_ROUND_CLOSEST(st->info->int_clk, st->clk_freq_hz);
> +		sync_scale = DIV_ROUND_CLOSEST(4000, st->clk_freq_hz);
>  
>  		if (3000 > sync_scale || 4500 < sync_scale)
>  			return dev_err_probe(dev, -EINVAL,
> @@ -955,7 +920,7 @@ static int adis16550_config_sync(struct adis16550 *st)
>  		if (ret)
>  			return ret;
>  
> -		st->clk_freq_hz = st->info->int_clk;
> +		st->clk_freq_hz = 4000;
>  	}
>  
>  	st->clk_freq_hz *= 1000;
> @@ -1064,13 +1029,11 @@ static int adis16550_probe(struct spi_device *spi)
>  		return -ENOMEM;
>  
>  	st = iio_priv(indio_dev);
> -	st->info = spi_get_device_match_data(spi);
> -	if (!st->info)
> -		return -EINVAL;
> +
>  	adis = &st->adis;
> -	indio_dev->name = st->info->name;
> -	indio_dev->channels = st->info->channels;
> -	indio_dev->num_channels = st->info->num_channels;
> +	indio_dev->name = "adis16550";
> +	indio_dev->channels = adis16550_channels;
> +	indio_dev->num_channels = ARRAY_SIZE(adis16550_channels);
>  	indio_dev->available_scan_masks = adis16550_channel_masks;
>  	indio_dev->info = &adis16550_info;
>  	indio_dev->modes = INDIO_DIRECT_MODE;
> @@ -1117,13 +1080,13 @@ static int adis16550_probe(struct spi_device *spi)
>  }
>  
>  static const struct spi_device_id adis16550_id[] = {
> -	{ "adis16550",  (kernel_ulong_t)&adis16550_chip_info},
> +	{ .name = "adis16550" },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(spi, adis16550_id);
>  
>  static const struct of_device_id adis16550_of_match[] = {
> -	{ .compatible = "adi,adis16550", .data = &adis16550_chip_info },
> +	{ .compatible = "adi,adis16550" },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(of, adis16550_of_match);
> -- 
> 2.47.3
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/3] iio: imu: adis16550: Simplify device abstraction
  2026-07-01 15:14   ` Nuno Sá
@ 2026-07-01 17:40     ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2026-07-01 17:40 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Uwe Kleine-König (The Capable Hub), Nuno Sá,
	Michael Hennerich, David Lechner, Andy Shevchenko, linux,
	linux-iio, linux-kernel

On Wed, 1 Jul 2026 16:14:47 +0100
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Tue, Jun 30, 2026 at 05:35:35PM +0200, Uwe Kleine-König (The Capable Hub) wrote:
> > The driver supports a single chip variant only. Simplify the driver by
> > hard-coding the device properties instead of using the id_table's
> > abstraction for a single chip type and a lookup in a table with only one
> > entry.
> > 
> > Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
> > ---  
> 
> LGTM
> 
> Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Applied.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-07-01 17:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30 15:35 [PATCH v2 0/3] iio: Use named initializers for device_id structures Uwe Kleine-König (The Capable Hub)
2026-06-30 15:35 ` [PATCH v2 1/3] iio: adc: ti-tsc2046: Simplify device handling Uwe Kleine-König (The Capable Hub)
2026-06-30 23:02   ` Jonathan Cameron
2026-07-01  4:41   ` Oleksij Rempel
2026-06-30 15:35 ` [PATCH v2 2/3] iio: imu: adis16550: Simplify device abstraction Uwe Kleine-König (The Capable Hub)
2026-07-01 15:14   ` Nuno Sá
2026-07-01 17:40     ` Jonathan Cameron
2026-06-30 15:35 ` [PATCH v2 3/3] staging: iio: Initialize spi_device_id arrays using member names Uwe Kleine-König (The Capable Hub)
2026-06-30 22:59   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox