Re: [PATCH v6] iio: chemical: scd30: Replace manual locking with RAII locking
From: Joshua Crofts
Date: Mon Jun 01 2026 - 09:35:21 EST
On Mon, 1 Jun 2026 at 01:38, Maxwell Doose <m32285159@xxxxxxxxx> 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() containing
> the critical section for scd30_trigger_handler().
>
> In addition, small refactor to replace "?:" operator with regular
> if/else returns.
>
> Signed-off-by: Maxwell Doose <m32285159@xxxxxxxxx>
> ---
> v2:
> - Fix callback issue as noted by Jonathan v1.
> - Refactor critical section of scd30_trigger_handler() into helper
> called scd30_trigger_handler_helper_locked().
> - Revert removal of goto in scd30_trigger_handler().
>
> v3:
> - Tune up helper to return early on failure condition per Jonathan's
> suggestion.
>
> v4:
> - Forgot to commit changes listed in v3, now fixed.
>
> v5:
> - Remove unneeded comment for scd30_trigger_handler_helper() per
> Jonathan's suggestion.
> - Change name of arr_size to scan_data_size per Jonathan's suggestion.
> - Change type of scan_data_size to size_t per Jonathan's suggestion.
> - Added blank line between return and the rest of the function body in
> scd30_trigger_handler_helper().
>
> v6:
> - Fix issue where names for scd30_trigger_handler_helper() did not
> match per Jonathan.
>
> drivers/iio/chemical/scd30_core.c | 66 ++++++++++++++++++++-----------
> 1 file changed, 42 insertions(+), 24 deletions(-)
FWIW,
Reviewed-by: Joshua Crofts <joshua.crofts1@xxxxxxxxx>
--
Kind regards
CJD