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

From: Andy Shevchenko

Date: Mon Jun 01 2026 - 14:52:39 EST


On Tue, May 19, 2026 at 08:19:43AM -0500, Maxwell Doose wrote:
> scd30_core.c currently uses manual mutex_lock() and mutex_unlock()
> calls. Replace them with the newer guard(mutex)() for cleaner RAII
> patterns and to improve maintainability.
>
> Add new helper function scd30_trigger_handler_helper_locked() containing
> the critical section for scd30_trigger_handler().
>
> In addition, small refactor to replace "?:" operator with regular
> if/else returns.

...

> + if (!iio_trigger_using_own(indio_dev))
> + ret = scd30_read_poll(state);
> + else
> + ret = scd30_read_meas(state);

Why not use positive conditional?


--
With Best Regards,
Andy Shevchenko