drivers/iio/adc/ad7173.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-)
Fix the num_slots value for most chips in the ad7173 driver. The number
of slots corresponds to the number of CHANNEL registers on each chip.
Fixes: 4310e15b3140 ("iio: adc: ad7173: don't make copy of ad_sigma_delta_info struct")
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
FYI, the bug actually existed before the commit I used for Fixes:, but
that commit did major refactoring involving multiple drivers that would
be too complicated to try to backport to older kernels.
I will try to send a separate fix to stable@ to fix the bug in it's
original form on older kernels as that is just a one-liner.
---
drivers/iio/adc/ad7173.c | 37 +++++++++++++++++++++++++++----------
1 file changed, 27 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c
index dd9fa35555c79ead5a1b88d1dc6cc3db122502be..9c197cea11eb955becf4b9b97246379fa9c5da13 100644
--- a/drivers/iio/adc/ad7173.c
+++ b/drivers/iio/adc/ad7173.c
@@ -771,10 +771,27 @@ static const struct ad_sigma_delta_info ad7173_sigma_delta_info_8_slots = {
.num_slots = 8,
};
+static const struct ad_sigma_delta_info ad7173_sigma_delta_info_16_slots = {
+ .set_channel = ad7173_set_channel,
+ .append_status = ad7173_append_status,
+ .disable_all = ad7173_disable_all,
+ .disable_one = ad7173_disable_one,
+ .set_mode = ad7173_set_mode,
+ .has_registers = true,
+ .has_named_irqs = true,
+ .supports_spi_offload = true,
+ .addr_shift = 0,
+ .read_mask = BIT(6),
+ .status_ch_mask = GENMASK(3, 0),
+ .data_reg = AD7173_REG_DATA,
+ .num_resetclks = 64,
+ .num_slots = 16,
+};
+
static const struct ad7173_device_info ad4111_device_info = {
.name = "ad4111",
.id = AD4111_ID,
- .sd_info = &ad7173_sigma_delta_info_8_slots,
+ .sd_info = &ad7173_sigma_delta_info_16_slots,
.num_voltage_in_div = 8,
.num_channels = 16,
.num_configs = 8,
@@ -796,7 +813,7 @@ static const struct ad7173_device_info ad4111_device_info = {
static const struct ad7173_device_info ad4112_device_info = {
.name = "ad4112",
.id = AD4112_ID,
- .sd_info = &ad7173_sigma_delta_info_8_slots,
+ .sd_info = &ad7173_sigma_delta_info_16_slots,
.num_voltage_in_div = 8,
.num_channels = 16,
.num_configs = 8,
@@ -817,7 +834,7 @@ static const struct ad7173_device_info ad4112_device_info = {
static const struct ad7173_device_info ad4113_device_info = {
.name = "ad4113",
.id = AD4113_ID,
- .sd_info = &ad7173_sigma_delta_info_8_slots,
+ .sd_info = &ad7173_sigma_delta_info_16_slots,
.num_voltage_in_div = 8,
.num_channels = 16,
.num_configs = 8,
@@ -836,7 +853,7 @@ static const struct ad7173_device_info ad4113_device_info = {
static const struct ad7173_device_info ad4114_device_info = {
.name = "ad4114",
.id = AD4114_ID,
- .sd_info = &ad7173_sigma_delta_info_8_slots,
+ .sd_info = &ad7173_sigma_delta_info_16_slots,
.num_voltage_in_div = 16,
.num_channels = 16,
.num_configs = 8,
@@ -855,7 +872,7 @@ static const struct ad7173_device_info ad4114_device_info = {
static const struct ad7173_device_info ad4115_device_info = {
.name = "ad4115",
.id = AD4115_ID,
- .sd_info = &ad7173_sigma_delta_info_8_slots,
+ .sd_info = &ad7173_sigma_delta_info_16_slots,
.num_voltage_in_div = 16,
.num_channels = 16,
.num_configs = 8,
@@ -874,7 +891,7 @@ static const struct ad7173_device_info ad4115_device_info = {
static const struct ad7173_device_info ad4116_device_info = {
.name = "ad4116",
.id = AD4116_ID,
- .sd_info = &ad7173_sigma_delta_info_8_slots,
+ .sd_info = &ad7173_sigma_delta_info_16_slots,
.num_voltage_in_div = 11,
.num_channels = 16,
.num_configs = 8,
@@ -893,7 +910,7 @@ static const struct ad7173_device_info ad4116_device_info = {
static const struct ad7173_device_info ad7172_2_device_info = {
.name = "ad7172-2",
.id = AD7172_2_ID,
- .sd_info = &ad7173_sigma_delta_info_8_slots,
+ .sd_info = &ad7173_sigma_delta_info_4_slots,
.num_voltage_in = 5,
.num_channels = 4,
.num_configs = 4,
@@ -926,7 +943,7 @@ static const struct ad7173_device_info ad7172_4_device_info = {
static const struct ad7173_device_info ad7173_8_device_info = {
.name = "ad7173-8",
.id = AD7173_ID,
- .sd_info = &ad7173_sigma_delta_info_8_slots,
+ .sd_info = &ad7173_sigma_delta_info_16_slots,
.num_voltage_in = 17,
.num_channels = 16,
.num_configs = 8,
@@ -943,7 +960,7 @@ static const struct ad7173_device_info ad7173_8_device_info = {
static const struct ad7173_device_info ad7175_2_device_info = {
.name = "ad7175-2",
.id = AD7175_2_ID,
- .sd_info = &ad7173_sigma_delta_info_8_slots,
+ .sd_info = &ad7173_sigma_delta_info_4_slots,
.num_voltage_in = 5,
.num_channels = 4,
.num_configs = 4,
@@ -960,7 +977,7 @@ static const struct ad7173_device_info ad7175_2_device_info = {
static const struct ad7173_device_info ad7175_8_device_info = {
.name = "ad7175-8",
.id = AD7175_8_ID,
- .sd_info = &ad7173_sigma_delta_info_8_slots,
+ .sd_info = &ad7173_sigma_delta_info_16_slots,
.num_voltage_in = 17,
.num_channels = 16,
.num_configs = 8,
---
base-commit: 6742eff60460e77158d4f1b233f17e0345c9e66a
change-id: 20250703-iio-adc-ad7173-fix-num_slots-on-most-chips-b982206a20b1
Best regards,
--
David Lechner <dlechner@baylibre.com>
Hi David,
kernel test robot noticed the following build errors:
[auto build test ERROR on 6742eff60460e77158d4f1b233f17e0345c9e66a]
url: https://github.com/intel-lab-lkp/linux/commits/David-Lechner/iio-adc-ad7173-fix-num_slots-on-most-chips/20250704-061744
base: 6742eff60460e77158d4f1b233f17e0345c9e66a
patch link: https://lore.kernel.org/r/20250703-iio-adc-ad7173-fix-num_slots-on-most-chips-v1-1-326c5d113e15%40baylibre.com
patch subject: [PATCH] iio: adc: ad7173: fix num_slots on most chips
config: x86_64-buildonly-randconfig-004-20250704 (https://download.01.org/0day-ci/archive/20250705/202507050018.iWEJiG04-lkp@intel.com/config)
compiler: clang version 20.1.7 (https://github.com/llvm/llvm-project 6146a88f60492b520a36f8f8f3231e15f3cc6082)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250705/202507050018.iWEJiG04-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507050018.iWEJiG04-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/iio/adc/ad7173.c:782:3: error: field designator 'supports_spi_offload' does not refer to any field in type 'const struct ad_sigma_delta_info'
782 | .supports_spi_offload = true,
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
vim +782 drivers/iio/adc/ad7173.c
773
774 static const struct ad_sigma_delta_info ad7173_sigma_delta_info_16_slots = {
775 .set_channel = ad7173_set_channel,
776 .append_status = ad7173_append_status,
777 .disable_all = ad7173_disable_all,
778 .disable_one = ad7173_disable_one,
779 .set_mode = ad7173_set_mode,
780 .has_registers = true,
781 .has_named_irqs = true,
> 782 .supports_spi_offload = true,
783 .addr_shift = 0,
784 .read_mask = BIT(6),
785 .status_ch_mask = GENMASK(3, 0),
786 .data_reg = AD7173_REG_DATA,
787 .num_resetclks = 64,
788 .num_slots = 16,
789 };
790
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On Thu, 03 Jul 2025 17:16:31 -0500
David Lechner <dlechner@baylibre.com> wrote:
> Fix the num_slots value for most chips in the ad7173 driver. The number
> of slots corresponds to the number of CHANNEL registers on each chip.
>
> Fixes: 4310e15b3140 ("iio: adc: ad7173: don't make copy of ad_sigma_delta_info struct")
> Signed-off-by: David Lechner <dlechner@baylibre.com>
Perhaps worth calling out that for many chips it seems to be falsely limiting
the number of slots which is a functionality limitation I think rather
than a bug. The ones going the other way are more of a problem though!
Jonathan
> ---
> FYI, the bug actually existed before the commit I used for Fixes:, but
> that commit did major refactoring involving multiple drivers that would
> be too complicated to try to backport to older kernels.
>
> I will try to send a separate fix to stable@ to fix the bug in it's
> original form on older kernels as that is just a one-liner.
> ---
> drivers/iio/adc/ad7173.c | 37 +++++++++++++++++++++++++++----------
> 1 file changed, 27 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c
> index dd9fa35555c79ead5a1b88d1dc6cc3db122502be..9c197cea11eb955becf4b9b97246379fa9c5da13 100644
> --- a/drivers/iio/adc/ad7173.c
> +++ b/drivers/iio/adc/ad7173.c
> @@ -771,10 +771,27 @@ static const struct ad_sigma_delta_info ad7173_sigma_delta_info_8_slots = {
> .num_slots = 8,
> };
>
> +static const struct ad_sigma_delta_info ad7173_sigma_delta_info_16_slots = {
> + .set_channel = ad7173_set_channel,
> + .append_status = ad7173_append_status,
> + .disable_all = ad7173_disable_all,
> + .disable_one = ad7173_disable_one,
> + .set_mode = ad7173_set_mode,
> + .has_registers = true,
> + .has_named_irqs = true,
> + .supports_spi_offload = true,
> + .addr_shift = 0,
> + .read_mask = BIT(6),
> + .status_ch_mask = GENMASK(3, 0),
> + .data_reg = AD7173_REG_DATA,
> + .num_resetclks = 64,
> + .num_slots = 16,
> +};
> +
> static const struct ad7173_device_info ad4111_device_info = {
> .name = "ad4111",
> .id = AD4111_ID,
> - .sd_info = &ad7173_sigma_delta_info_8_slots,
> + .sd_info = &ad7173_sigma_delta_info_16_slots,
> .num_voltage_in_div = 8,
> .num_channels = 16,
> .num_configs = 8,
> @@ -796,7 +813,7 @@ static const struct ad7173_device_info ad4111_device_info = {
> static const struct ad7173_device_info ad4112_device_info = {
> .name = "ad4112",
> .id = AD4112_ID,
> - .sd_info = &ad7173_sigma_delta_info_8_slots,
> + .sd_info = &ad7173_sigma_delta_info_16_slots,
> .num_voltage_in_div = 8,
> .num_channels = 16,
> .num_configs = 8,
> @@ -817,7 +834,7 @@ static const struct ad7173_device_info ad4112_device_info = {
> static const struct ad7173_device_info ad4113_device_info = {
> .name = "ad4113",
> .id = AD4113_ID,
> - .sd_info = &ad7173_sigma_delta_info_8_slots,
> + .sd_info = &ad7173_sigma_delta_info_16_slots,
> .num_voltage_in_div = 8,
> .num_channels = 16,
> .num_configs = 8,
> @@ -836,7 +853,7 @@ static const struct ad7173_device_info ad4113_device_info = {
> static const struct ad7173_device_info ad4114_device_info = {
> .name = "ad4114",
> .id = AD4114_ID,
> - .sd_info = &ad7173_sigma_delta_info_8_slots,
> + .sd_info = &ad7173_sigma_delta_info_16_slots,
> .num_voltage_in_div = 16,
> .num_channels = 16,
> .num_configs = 8,
> @@ -855,7 +872,7 @@ static const struct ad7173_device_info ad4114_device_info = {
> static const struct ad7173_device_info ad4115_device_info = {
> .name = "ad4115",
> .id = AD4115_ID,
> - .sd_info = &ad7173_sigma_delta_info_8_slots,
> + .sd_info = &ad7173_sigma_delta_info_16_slots,
> .num_voltage_in_div = 16,
> .num_channels = 16,
> .num_configs = 8,
> @@ -874,7 +891,7 @@ static const struct ad7173_device_info ad4115_device_info = {
> static const struct ad7173_device_info ad4116_device_info = {
> .name = "ad4116",
> .id = AD4116_ID,
> - .sd_info = &ad7173_sigma_delta_info_8_slots,
> + .sd_info = &ad7173_sigma_delta_info_16_slots,
> .num_voltage_in_div = 11,
> .num_channels = 16,
> .num_configs = 8,
> @@ -893,7 +910,7 @@ static const struct ad7173_device_info ad4116_device_info = {
> static const struct ad7173_device_info ad7172_2_device_info = {
> .name = "ad7172-2",
> .id = AD7172_2_ID,
> - .sd_info = &ad7173_sigma_delta_info_8_slots,
> + .sd_info = &ad7173_sigma_delta_info_4_slots,
> .num_voltage_in = 5,
> .num_channels = 4,
> .num_configs = 4,
> @@ -926,7 +943,7 @@ static const struct ad7173_device_info ad7172_4_device_info = {
> static const struct ad7173_device_info ad7173_8_device_info = {
> .name = "ad7173-8",
> .id = AD7173_ID,
> - .sd_info = &ad7173_sigma_delta_info_8_slots,
> + .sd_info = &ad7173_sigma_delta_info_16_slots,
> .num_voltage_in = 17,
> .num_channels = 16,
> .num_configs = 8,
> @@ -943,7 +960,7 @@ static const struct ad7173_device_info ad7173_8_device_info = {
> static const struct ad7173_device_info ad7175_2_device_info = {
> .name = "ad7175-2",
> .id = AD7175_2_ID,
> - .sd_info = &ad7173_sigma_delta_info_8_slots,
> + .sd_info = &ad7173_sigma_delta_info_4_slots,
> .num_voltage_in = 5,
> .num_channels = 4,
> .num_configs = 4,
> @@ -960,7 +977,7 @@ static const struct ad7173_device_info ad7175_2_device_info = {
> static const struct ad7173_device_info ad7175_8_device_info = {
> .name = "ad7175-8",
> .id = AD7175_8_ID,
> - .sd_info = &ad7173_sigma_delta_info_8_slots,
> + .sd_info = &ad7173_sigma_delta_info_16_slots,
> .num_voltage_in = 17,
> .num_channels = 16,
> .num_configs = 8,
>
> ---
> base-commit: 6742eff60460e77158d4f1b233f17e0345c9e66a
> change-id: 20250703-iio-adc-ad7173-fix-num_slots-on-most-chips-b982206a20b1
>
> Best regards,
© 2016 - 2026 Red Hat, Inc.