Re: [PATCH v8] iio: magnetometer: bmc150_magn: use automated cleanup for mutex

From: Jonathan Cameron

Date: Mon Mar 02 2026 - 17:44:19 EST


On Mon, 2 Mar 2026 10:21:11 +0200
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:

> On Sun, Mar 01, 2026 at 11:56:33AM +0000, Jonathan Cameron wrote:
> > On Sat, 28 Feb 2026 12:23:20 -0500
> > Neel Bullywon <neelb2403@xxxxxxxxx> wrote:
> >
> > > Use guard() and scoped_guard() to replace manual mutex lock/unlock
> > > calls. This simplifies error handling and ensures RAII-style cleanup.
> > >
> > > guard() is used in read_raw, write_raw, trig_reen, and
> > > trigger_set_state. Case blocks using guard() in read_raw and write_raw
> > > are wrapped in braces at the case label level to ensure clear scope for
> > > the cleanup guards.
> > >
> > > A bmc150_magn_set_power_mode_locked() helper is added to deduplicate
> > > the lock-call-unlock pattern used by remove, runtime_suspend, suspend,
> > > and resume.
> > >
> > > The trigger_handler function is left unchanged as mixing guard() with
> > > goto error paths can be fragile.
> > >
> > > Signed-off-by: Neel Bullywon <neelb2403@xxxxxxxxx>
> > Hi Neel
> >
> > LGTM, but I'll leave some time for Andy to take another look if he
> > wants to.
>
> I briefly looked and I'm fine with the code, but I haven't reviewed it fully,
> hence
>
> Acked-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
>

Applied. Thanks

J