Re: [PATCH] iio: light: adux1020: use guard() to simplify lock handling
From: Andy Shevchenko
Date: Mon Nov 09 2026 - 15:05:29 EST
On Sun, Nov 08, 2026 at 08:16:13PM +0000, Raffaele Tranfaglia via B4 Relay wrote:
>
> Use guard(mutex) in adux1020_read_raw(), adux1020_write_raw() and
> adux1020_write_event_config() so the lock is released automatically on
> return. This allows returning directly instead of jumping to a common
> unlock label, and lets adux1020_write_raw() drop its ret variable.
>
> No functional change intended.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
...
> Suggested-by: Jonathan Cameron <jic23@xxxxxxxxxx>
> Link: https://lore.kernel.org/all/20261107222957.5332237b@jic23-hlaptop/
It's not recommended to put unreferenced Link tags.
...
> static int adux1020_read_raw(struct iio_dev *indio_dev,
> {
> struct adux1020_data *data = iio_priv(indio_dev);
> u16 buf[3];
> - int ret = -EINVAL;
> + int ret;
> unsigned int regval;
While at it you can move 'ret' to be the last in the definition block.
--
With Best Regards,
Andy Shevchenko