Re: [PATCH 2/2] iio: adc: ti-ads112c14: add continuous mode support

From: David Lechner

Date: Mon Jul 27 2026 - 10:09:20 EST


On 7/26/26 8:45 PM, Jonathan Cameron wrote:
> On Fri, 24 Jul 2026 15:13:11 -0500
> "David Lechner (TI)" <dlechner@xxxxxxxxxxxx> wrote:
>
>> Add support for continuous mode in the TI ADS112C14 ADC driver. In this
>> mode the ADC itself is starting each conversion, so we add a trigger
>> based on the DRDY interrupt to read each sample. This mode is also
>> limited in that only one channel can be enabled at a time since the
>> chip does not have a sequencer or simultaneous sampling capability.
>> Continuous mode will only be used when this new trigger is the current
>> trigger.
>>

...

>> +static int ads112c14_buffer_predisable(struct iio_dev *indio_dev)
>> +{
>> + struct ads112c14_data *data = iio_priv(indio_dev);
>> + int ret, ret2;
>> +
>> + if (!ads112c14_using_drdy_trigger(indio_dev))
>> + return 0;
>> +
>> + guard(mutex)(&data->lock);
>> +
>> + ret = regmap_write(data->regmap, ADS112C14_REG_CONVERSION_CTRL,
>> + ADS112C14_CONVERSION_CTRL_STOP);
>> + ret2 = regmap_assign_bits(data->regmap, ADS112C14_REG_DEVICE_CFG,
>> + ADS112C14_DEVICE_CFG_CONV_MODE,
>> + ADS112C14_DEVICE_CFG_CONV_MODE_SINGLE_SHOT);
>
> This is odd looking code. Needs comments on why we should prefer returning
> the error for the second call over that for the first.

It is arbitrary, I just went with first error wins.

Other option would be to return early since the hardware is going to
be in a broken state anyway.

>
>> + if (ret2)
>> + return ret2;
>> +
>> + return ret;
>> +}
>
>