On Wed, 27 Nov 2024 10:06:13 +0100 Guillaume Ranquet <granquet@xxxxxxxxxxxx> wrote: > The ad7173 family of chips has up to four calibration modes. > > Internal zero scale: removes ADC core offset errors. > Internal full scale: removes ADC core gain errors. > System zero scale: reduces offset error to the order of channel noise. > System full scale: reduces gain error to the order of channel noise. > > All voltage channels will undergo an internal zero/full scale > calibration at bootup. > > System zero/full scale can be done after bootup using the newly created > iio interface 'sys_calibration' and 'sys_calibration_mode' > > Signed-off-by: Guillaume Ranquet <granquet@xxxxxxxxxxxx> > static const struct iio_chan_spec ad7173_temp_iio_channel_template = { > @@ -1213,6 +1329,7 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev) > struct iio_chan_spec *chan_arr, *chan; > unsigned int ain[AD7173_NO_AINS_PER_CHANNEL], chan_index = 0; > int ref_sel, ret, num_channels; > + u8 *calib_mode; > > num_channels = device_get_child_node_count(dev); > > @@ -1240,8 +1357,14 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev) > if (!chans_st_arr) > return -ENOMEM; > > + calib_mode = devm_kcalloc(dev, st->num_channels, sizeof(*st->syscalib_mode), > + GFP_KERNEL); As it is per channel, can we put it in struct ad7173_channel? This driver already has a lot of small allocations. Avoiding an extra one would nice! > + if (!calib_mode) > + return -ENOMEM; > + > indio_dev->channels = chan_arr; > st->channels = chans_st_arr; > + st->syscalib_mode = calib_mode; > > if (st->info->has_temp) { > chan_arr[chan_index] = ad7173_temp_iio_channel_template; >