Re: [PATCH v4 04/10] iio: adc: ti-ads1262: support per-channel sampling frequency

From: Jonathan Cameron

Date: Sat Aug 29 2026 - 21:36:38 EST


On Fri, 28 Aug 2026 01:38:19 -0500
Kurt Borja <kuurtb@xxxxxxxxx> wrote:

> Add per-channel sampling frequency support. The "available" attribute is
> assigned per-channel too, in order to eventually support per-filter
> availability.
>
> Signed-off-by: Kurt Borja <kuurtb@xxxxxxxxx>
A build issue below.

> };
>
> +static const struct ads1262_channel ads1262_default_channel = {
> + .data_rate = ADS1262_DR_20_SPS,
> + .filter = ADS1262_FILTER_FIR,
> +};

See below - this probably wants to be a slightly more complex define.



> @@ -763,8 +970,15 @@ static int ads1262_parse_channels(struct iio_dev *indio_dev)
> if (!chan_specs)
> return -ENOMEM;
>
> + st->num_channels = num_fw_channels + ADS1262_MON_CHANNEL_COUNT;
> + st->channels = devm_kcalloc(dev, st->num_channels, sizeof(*st->channels),
> + GFP_KERNEL);
> + if (!st->channels)
> + return -ENOMEM;
> +
> device_for_each_named_child_node_scoped(dev, node, "channel") {
> struct iio_chan_spec *spec = &chan_specs[i];
> + struct ads1262_channel *chan = &st->channels[i];
>
> ret = fwnode_property_read_u32(node, "reg", &reg);
> if (ret)
> @@ -772,6 +986,8 @@ static int ads1262_parse_channels(struct iio_dev *indio_dev)
> if (reg >= ADS1262_MONITOR_ADDR_OFFSET)
> return dev_err_probe(dev, -EINVAL, "%pfwP: reg out of range\n", node);
>
> + *chan = (struct ads1262_channel)ads1262_default_channel;

This is giving me a build warning:

drivers/iio/adc/ti-ads1262.c:1913:26: warning: cast to non-scalar
drivers/iio/adc/ti-ads1262.c:1913:26: warning: cast from non-scalar

So we can't do this... Hmm. It's pretty simply. Use a define for
the default channel with the (struct adds1262_channel)
and that should work for us.

> +
> ret = ads1262_parse_channel_node(st, spec, node);
> if (ret)
> return ret;
> @@ -786,7 +1002,9 @@ static int ads1262_parse_channels(struct iio_dev *indio_dev)
> .storagebits = 32,
> .endianness = IIO_BE,
> };
> - spec->info_mask_separate = BIT(IIO_CHAN_INFO_RAW);
> + spec->info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> + BIT(IIO_CHAN_INFO_SAMP_FREQ);
> + spec->info_mask_separate_available = BIT(IIO_CHAN_INFO_SAMP_FREQ);
>
> i++;
> }
> @@ -795,6 +1013,7 @@ static int ads1262_parse_channels(struct iio_dev *indio_dev)
> sizeof(ads1262_monitor_chan_specs));
>
> for (unsigned int mon = 0; mon < ADS1262_MON_CHANNEL_COUNT; mon++) {
> + st->channels[i] = (struct ads1262_channel)ads1262_default_channel;
Same here - a define would allow this to work rather than giving build
problems as it currently does.

> chan_specs[i].scan_index = i;
> i++;
> }
> @@ -890,6 +1109,10 @@ static int ads1262_spi_probe(struct spi_device *spi)
>
> indio_dev->name = ads1262_device_id_to_name[st->dev_id];
>
> + ret = ads1262_populate_tables(indio_dev);
> + if (ret)
> + return ret;
> +
> /*
> * REVISIT: This chip has software polling capabilities, which could be
> * used to stop depending on the DRDY signal.
>