Re: [PATCH v3 10/10] iio: accel: mma8452: use guard() to release mutexes

Andy Shevchenko
2026-05-06T09:46:19Z

On Tue, May 05, 2026 at 11:16:40PM +0530, Sanjay Chitroda wrote:

> Replace explicit mutex_lock() and mutex_unlock() with the guard() and
> scoped_guard() macro for cleaner and safer mutex handling.

...

> static int mma8452_read_raw(struct iio_dev *indio_dev,

> IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim);
> if (IIO_DEV_ACQUIRE_FAILED(claim))
> return -EBUSY;

+ Blank line here.

> + guard(mutex)(&data->lock);
>
> - mutex_lock(&data->lock);
> ret = mma8452_read(data, buffer);
> - mutex_unlock(&data->lock);

Perhaps okay, also scoped_guard() can be used, but I have no strong opinion.

> if (ret < 0)
> return ret;

--
With Best Regards,
Andy Shevchenko