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

David Lechner <[email protected]> Sun, 2 Aug 2026 14:05:58 -0500
Newsgroups org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On 8/2/26 1:17 PM, Jonathan Cameron wrote:
> On Fri, 31 Jul 2026 18:48:12 -0500
> "David Lechner (TI)" <[email protected]> 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.
>>
>> Signed-off-by: David Lechner (TI) <[email protected]>
> There is some follow on stuff in here from the earlier suggestion to
> check the status register even when datardy involved
> 
>> ---
>>  drivers/iio/adc/ti-ads112c14.c | 146 ++++++++++++++++++++++++++++++++++++++++-
>>  1 file changed, 144 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/iio/adc/ti-ads112c14.c b/drivers/iio/adc/ti-ads112c14.c
>> index c6d83298c312..5147d10785fb 100644
>> --- a/drivers/iio/adc/ti-ads112c14.c
>> +++ b/drivers/iio/adc/ti-ads112c14.c
>> @@ -9,6 +9,7 @@
>>   */
>>  
>>  #include <linux/bitfield.h>
>> +#include <linux/bitmap.h>
>>  #include <linux/cleanup.h>
>>  #include <linux/completion.h>
>>  #include <linux/crc8.h>
>> @@ -18,6 +19,7 @@
>>  #include <linux/i2c.h>
>>  #include <linux/iio/buffer.h>
>>  #include <linux/iio/iio.h>
>> +#include <linux/iio/trigger.h>
>>  #include <linux/iio/trigger_consumer.h>
>>  #include <linux/iio/triggered_buffer.h>
>>  #include <linux/interrupt.h>
>> @@ -257,6 +259,7 @@ struct ads112c14_measurement {
>>  struct ads112c14_data {
>>  	const struct ads112c14_chip_info *chip_info;
>>  	struct regmap *regmap;
>> +	struct iio_trigger *drdy_trig;
>>  	/* Synchronizes access to register value fields. */
>>  	struct mutex lock;
>>  	int drdy_irq;
>> @@ -280,11 +283,32 @@ static irqreturn_t ads112c14_drdy_irq_handler(int irq, void *private)
>>  	struct iio_dev *indio_dev = private;
>>  	struct ads112c14_data *data = iio_priv(indio_dev);
>>  
>> -	complete(&data->drdy_completion);
>> +	if (indio_dev->trig && iio_trigger_using_own(indio_dev))
>> +		iio_trigger_poll(data->drdy_trig);
> 
> Even for this path we should be checking it wasn't a spurious interrupt.
> If that's happening in a threaded interrupt we'll then call iio_trigger_poll_nested()
> and the handler will happen in the interrupt thread.   So the overhead
> of that check should just be the check.
> 
For now, I think we'll not bother with checking for spurious interrupts.
The only reason it should happen is electrical noise (or disconnecting
wires on a live system). And we can add it in a follow up patch if we
decide we need it. The overhead of an extra read for each sample might be
a bit much at the higher sample rates. So we'll want to implement the
higher sample rates first anyway.

We can read the status along with the data in a single transfer, so that
might be a more efficient way to do it too.