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

From: Maxwell Doose

Date: Sat May 09 2026 - 17:45:50 EST


On Sat, May 9, 2026 at 4:22 PM David Lechner <dlechner@xxxxxxxxxxxx> wrote:
[snip]
> Doesn't need to be scoped. there is just return after this.
>
> > + ret = state->ops->clean_fan(state);
> > +
> > if (ret)
> > return ret;
> >

Ah. Idea was to keep lengths of critical sections as close as possible
to what they were before just to be safe. Will change all of those
over for v2.

best regards,
max

> > @@ -215,9 +216,9 @@ static ssize_t cleaning_period_show(struct device *dev,
> > __be32 val;
> > int ret;
> >
> > - mutex_lock(&state->lock);
> > - ret = state->ops->read_cleaning_period(state, &val);
> > - mutex_unlock(&state->lock);
> > + scoped_guard(mutex, &state->lock)
> > + ret = state->ops->read_cleaning_period(state, &val);
> > +
>
> IMHO, this one just make the code uglier, not really an improvement.
>
> > if (ret)
> > return ret;
> >