Re: [PATCH RESEND v3 12/17] iio: adc: ad7768-1: Add GPIO controller support
From: David Lechner
Date: Thu Feb 20 2025 - 17:27:36 EST
On 2/19/25 2:34 PM, Linus Walleij wrote:
> Hi Jonathan/Sergiu,
>
> thanks for your patch!
>
> On Wed, Feb 12, 2025 at 7:20 PM Jonathan Santos
> <Jonathan.Santos@xxxxxxxxxx> wrote:
>
>> From: Sergiu Cuciurean <sergiu.cuciurean@xxxxxxxxxx>
>>
>> The AD7768-1 has the ability to control other local hardware (such as gain
>> stages),to power down other blocks in the signal chain, or read local
>> status signals over the SPI interface.
>>
>> This change exports the AD7768-1's four gpios and makes them accessible
>> at an upper layer.
>>
>> Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@xxxxxxxxxx>
>> Co-developed-by: Jonathan Santos <Jonathan.Santos@xxxxxxxxxx>
>> Signed-off-by: Jonathan Santos <Jonathan.Santos@xxxxxxxxxx>
>
> Is it not possible to use the gpio regmap library in this driver
> like we do in drivers/iio/addac/stx104.c?
>
> It cuts down the code size of simple GPIO chips on random
> chips quite a lot.
>
> Yours,
> Linus Walleij
I think the answer is "no" since we need to hold a conditional lock
while accessing registers. Namely: iio_device_claim_direct_mode()/
iio_device_release_direct_mode().
Unless we add some extra stuff to the gpio regmap implementation to
add optional callbacks to call these. Which could be worth it given
that quite a few ADCs provide GPIOs like this.