iio: Use named initializers for device_id structures
Subsystems (5)
v2 cover iio: Use named initializers for device_id structures
Hello,
v1 of this series can be found at
https://lore.kernel.org/linux-iio/[email protected]
.
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
Signature · 1 line
2.47.3
PATCH v2 1/3 iio: adc: ti-tsc2046: Simplify device handling
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.
--- drivers/iio/adc/ti-tsc2046.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)
drivers/iio/adc/ti-tsc2046.c +4 -21
@@ -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);
Signature · 1 line
2.47.3
Jonathan Cameron
maintainerRe: [PATCH v2 1/3] iio: adc: ti-tsc2046: Simplify device handling
Quoted 8 lines · On Tue, 30 Jun 2026 17:35:34 +0200 Uwe Kleine-König (The Capable Hub)…
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) <[email protected]>
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
Quoted 92 lines
--- drivers/iio/adc/ti-tsc2046.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)drivers/iio/adc/ti-tsc2046.c +4
-21@@ -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);
Re: [PATCH v2 1/3] iio: adc: ti-tsc2046: Simplify device handling
In reply to Uwe Kleine-König (The Capable Hub)Quoted 8 lines · Uwe Kleine-König (The Capable Hub)
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) <[email protected]>
LGTM - Thank you!
Signature · 4 lines
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 |
PATCH v2 2/3 iio: imu: adis16550: Simplify device abstraction
In reply to Uwe Kleine-König (The Capable Hub)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.
--- drivers/iio/imu/adis16550.c | 89 +++++++++++-------------------------- 1 file changed, 26 insertions(+), 63 deletions(-)
drivers/iio/imu/adis16550.c +26 -63
@@ -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);
Signature · 1 line
2.47.3
Re: [PATCH v2 2/3] iio: imu: adis16550: Simplify device abstraction
Quoted 7 lines · Uwe Kleine-König (The Capable Hub)
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) <[email protected]>---
LGTM
Quoted 200 lines
drivers/iio/imu/adis16550.c | 89 +++++++++++-------------------------- 1 file changed, 26 insertions(+), 63 deletions(-)drivers/iio/imu/adis16550.c +26
-63@@ -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);Signature · 1 line
2.47.3
Re: [PATCH v2 2/3] iio: imu: adis16550: Simplify device abstraction
Quoted 6 lines · On Wed, 1 Jul 2026 16:14:47 +0100 Nuno Sá <[email protected]> wrote:
Quoted 5 lines · Uwe Kleine-König (The Capable Hub)
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.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Uwe Kleine-König (The Capable Hub) <[email protected]>---
LGTM
Reviewed-by Nuno Sá <[email protected]>
Applied.
PATCH v2 3/3 staging: iio: Initialize spi_device_id arrays using member names
In reply to Uwe Kleine-König (The Capable Hub)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.
--- drivers/staging/iio/adc/ad7816.c | 6 +++--- drivers/staging/iio/frequency/ad9834.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/staging/iio/adc/ad7816.c +3 -3
@@ -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 }, { } };
drivers/staging/iio/frequency/ad9834.c +4 -4
@@ -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);
Signature · 1 line
2.47.3
Jonathan Cameron
maintainerRe: [PATCH v2 3/3] staging: iio: Initialize spi_device_id arrays using member names
Quoted 8 lines · On Tue, 30 Jun 2026 17:35:36 +0200 Uwe Kleine-König (The Capable Hub)…
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_idthat replaces .driver_data by an anonymous union.
Quoted 7 lines
This patch doesn't modify the compiled arrays, only their representation in source form benefits. The former was confirmed with x86 and arm64 builds.
Given I messed up applying this in v1, picked up now.
Thanks for catching that miss!
Jonathan
Quoted 41 lines
--- drivers/staging/iio/adc/ad7816.c | 6 +++--- drivers/staging/iio/frequency/ad9834.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-)drivers/staging/iio/adc/ad7816.c +3
-3@@ -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 }, { } };drivers/staging/iio/frequency/ad9834.c +4
-4@@ -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);