Re: [PATCH v4] iio: chemical: sps30: Replace manual locking with RAII locking

From: Maxwell Doose

Date: Wed May 20 2026 - 16:07:29 EST


On Wed, May 20, 2026 at 2:04 PM Jonathan Cameron <jic23@xxxxxxxxxx> wrote:
>
> On Wed, 20 May 2026 11:49:33 -0500
> Maxwell Doose <m32285159@xxxxxxxxx> wrote:
>
> > On Wed, May 20, 2026 at 7:22 AM Stepan Ionichev <sozdayvek@xxxxxxxxx> wrote:
> > >
> > > The hunk in sps30_read_raw() adds an empty line before "default:" in
> > > the switch, which is unrelated to the RAII conversion and probably
> > > worth dropping.
> > >
> >
> > First one is a stray change, my bad.
> >
> >
> > > Also, moving guard(mutex) into sps30_do_meas() changes its contract:
> > > previously callers had to hold state->lock around the call, now the
> > > function takes it itself. A line in the commit log would help future
> > > readers avoid the obvious "I'll just wrap it in mutex_lock()" pitfall.
> > >
> > > Stepan
> >
> > See:
> > >> Add guard(mutex)() into sps30_do_meas() as every caller locks it's call.
> >
> > Basic but still denotes that sps30_do_meas() holds the lock.
>
> I'd tweak to something a tiny bit more detailed like
>
> Move mutex locking (and switch to guard()) into sps30_do_meas() as every
> caller takes the lock just for this call.
>

Will do, while I'm at it I'll also fix the stray whitespace.

best regards,
max



> >
> > best regards,
> > max
> >
>