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

From: Maxwell Doose

Date: Sat May 23 2026 - 14:05:19 EST


On Fri, May 22, 2026 at 11:57 PM 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_locked() containing
> the critical section for scd30_trigger_handler(). After moving
> scd30_trigger_handler()'s critical section into the new helper, tune up
> control logic to return ret early and not memcpy() if it's an error
> condition.
>
> 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.
>
> drivers/iio/chemical/scd30_core.c | 66 ++++++++++++++++++++-----------
> 1 file changed, 42 insertions(+), 24 deletions(-)
>
[snip]

Disregard, I'm losing my marbles haha. Apparently I forgot to commit
my changes...will fix very shortly.

best regards,
max