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

From: Matheus Giarola

Date: Wed Apr 01 2026 - 23:08:18 EST


On Tue, Mar 31, 2026 at 4:24 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxx> wrote:
>
> On Tue, Mar 31, 2026 at 12:31:59PM -0300, Matheus Giarola wrote:
> > Use guard(mutex) instead of mutex_lock()/mutex_unlock(),
> > ensuring the mutex is released automatically when leaving
> > the function scope. The change improves error handling and
> > avoids issues such as missing unlocks. It also simplifies the
> > code by removing 'err_unlock' label and several mutex_unlock()
> > calls.
> >
> > As suggested, in ad7280_read_raw(), wrap the IIO_CHAN_INFO_RAW
> > case in braces, providing a scope for the implicit variable
> > declared by guard(mutex).
>
> ...
>
> > Reported-by: kernel test robot <lkp@xxxxxxxxx>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202603210357.KTWqlL36-lkp@xxxxxxxxx/
> > Closes: https://lore.kernel.org/oe-kbuild-all/202603210411.t4KwH3aX-lkp@xxxxxxxxx/
>
> It can't be right. The bugs LKP reported are in your patch and not in the Linux
> kernel as of today.
Hi Andy,
Thanks for pointing out the wrong tags, I'll fix it and send another version.

Thanks,
Matheus.
>
> --
> With Best Regards,
> Andy Shevchenko
>
>