Re: [PATCH v3 2/2] iio: adc: Add ti-ads1018 driver
From: Kurt Borja
Date: Mon Dec 01 2025 - 14:47:16 EST
On Mon Dec 1, 2025 at 11:07 AM -05, David Lechner wrote:
...
>>>> + if (iio_device_claim_buffer_mode(indio_dev))
>>>> + goto out_notify_done;
>>>> +
>>>> + if (iio_trigger_using_own(indio_dev)) {
>>>> + disable_irq(ads1018->drdy_irq);
>>>> + ret = ads1018_read_unlocked(ads1018, &scan.conv, true);
>>>> + enable_irq(ads1018->drdy_irq);
>>>> + } else {
>>>> + ret = spi_read(ads1018->spi, ads1018->rx_buf, sizeof(ads1018->rx_buf));
>>>> + scan.conv = ads1018->rx_buf[0];
>>>> + }
>>>> +
>>>> + iio_device_release_buffer_mode(indio_dev);
>>>> +
>>>> + if (ret)
>>>> + goto out_notify_done;
>>>> +
>>>> + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), pf->timestamp);
>>>> +
>>>> +out_notify_done:
>>>> + iio_trigger_notify_done(ads1018->indio_trig);
>>>
>>> Jonathan et al., maybe we need an ACQUIRE() class for this? It will solve
>>> the conditional scoped guard case, no?
>
> No, ACQUIRE() is not scoped, just conditional. I don't think it
> will improve anything here.
Maybe I'm not understanding the problem fully?
I interpreted "ACQUIRE() class" as a general GUARD class, i.e.
guard(iio_trigger_notify)(indio_dev->trig);
This way drivers may use other cleanup.h helpers cleaner, because of the
goto problem?
I do think it's a good idea, like a `defer` keyword. But it is a bit
unorthodox using guard for non locks.
--
~ Kurt