Re: [PATCH 1/4] iio: magnetometer: rm3100: Use scoped_guard() in rm3100_read_mag()

From: Andy Shevchenko

Date: Tue Apr 28 2026 - 04:37:35 EST


On Mon, Apr 27, 2026 at 09:43:36PM -0500, Maxwell Doose wrote:
> Replace mutex_lock() and mutex_unlock() calls in rm3100_read_mag() with
> the more modern scoped_guard(). This will help modernize the driver and
> bring it up-to-date with modern available macros/functions.
>
> While at it, remove the now unnecessary "unlock_return" goto and
> directly return in if statements.

...

> + scoped_guard(mutex, &data->lock) {

> + }

While this is strictly correct change, I would prefer to see guard()() for the
sake of less unneeded noise in the change.

> *val = sign_extend32(get_unaligned_be24(&buffer[0]), 23);

Yep, this will become part of the critical section, but taking into account
the size of the rest (and how much CPU cycles it might take at run-time)
I do not believe this piece of memory access with sign extension algo will
anyhow affect the duration of execution of the critical section.

> return IIO_VAL_INT;

--
With Best Regards,
Andy Shevchenko