Re: [PATCH v5] iio: adc: ad7280a: replace mutex_lock() with guard(mutex)

From: Andy Shevchenko

Date: Wed Apr 22 2026 - 03:47:12 EST


On Wed, Apr 22, 2026 at 10:44:36AM +0300, Andy Shevchenko wrote:
> On Tue, Apr 21, 2026 at 04:08:55PM -0300, Matheus Giarola wrote:

...

> > static ssize_t ad7280_show_balance_timer(struct iio_dev *indio_dev,
>
> > unsigned int msecs;
> > int ret;
> >
> > - mutex_lock(&st->lock);
> > - ret = ad7280_read_reg(st, chan->address >> 8,
> > + scoped_guard(mutex, &st->lock) {
> > + ret = ad7280_read_reg(st, chan->address >> 8,
> > (chan->address & 0xFF) + AD7280A_CB1_TIMER_REG);
> > - mutex_unlock(&st->lock);
> > + }
>
> Not sure if we need {} here (as it's one statement body), but the indentation
> now got broken of the second line there.
>
> What about
>
> u8 devaddr = chan->address >> 8;
> u8 addr = chan->address;

Just checked the second one s/addr/ch/ as per ad7280_store_balance_sw()
implementation.

> // ...or use existing names in the driver for the same things
>
> scoped_guard(mutex, &st->lock)
> ret = ad7280_read_reg(st, devaddr, addr + AD7280A_CB1_TIMER_REG);
>
> ?

--
With Best Regards,
Andy Shevchenko