Re: [PATCH v2] iio: imu: kmx61: Use guard(mutex)() family over manual locking

From: Andy Shevchenko

Date: Tue May 05 2026 - 03:26:54 EST


On Mon, May 04, 2026 at 11:46:04PM -0500, Maxwell Doose wrote:
> On Mon, May 4, 2026 at 7:55 PM Maxwell Doose <m32285159@xxxxxxxxx> wrote:
> >
> > Include linux/cleanup.h to take advantage of new macros.
> >
> > Replace manual mutex_lock() and mutex_unlock() calls across the file
> > with guard(mutex)() and scoped_guard() where appropriate. This will help
> > modernize the driver with up-to-date functions/macros.
> >
> > Remove now redundant gotos and ret variables, as the new RAII macros
> > make them unneeded.

[snip]

> I just got the report in from the CI bot on the v1, and there are
> still things in this patch that need to be fixed, consider this
> superseded. I'm going to be writing a v3 in the morning (my time) to
> resolve this.

Yes, you need to have a dedicated scope for guard()(). So, each case
in the switch that uses guard has to define the scope, id est be like

case FOO: {
...
break; // or return ...;
}

--
With Best Regards,
Andy Shevchenko