diff options
| author | Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com> | 2026-04-20 15:34:45 +0400 |
|---|---|---|
| committer | Jonathan Cameron <jic23@kernel.org> | 2026-04-27 09:58:23 +0100 |
| commit | 0179a95bbb8ce2fc36ba3766c7db5c7b4dd180b9 (patch) | |
| tree | 48f04fd9413e3d112c2665f912a1a1ff2cff0625 /drivers | |
| parent | ce80292ead5bb42b50a6b63e44fd95c0edf9d334 (diff) | |
| download | linux-0179a95bbb8ce2fc36ba3766c7db5c7b4dd180b9.tar.gz linux-0179a95bbb8ce2fc36ba3766c7db5c7b4dd180b9.zip | |
iio: adc: ti-ads7924: Use guard(mutex) in ADC read helper
Replace mutex_lock()/mutex_unlock() pair with guard(mutex)()
and move the lock into ads7924_get_adc_result(). Keeping the guard
in the helper makes the locking scope match the operation being protected.
Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/iio/adc/ti-ads7924.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/iio/adc/ti-ads7924.c b/drivers/iio/adc/ti-ads7924.c index bbcc4fc22b6e..5f294595a415 100644 --- a/drivers/iio/adc/ti-ads7924.c +++ b/drivers/iio/adc/ti-ads7924.c @@ -12,6 +12,7 @@ */ #include <linux/bitfield.h> +#include <linux/cleanup.h> #include <linux/delay.h> #include <linux/gpio/consumer.h> #include <linux/init.h> @@ -198,6 +199,8 @@ static int ads7924_get_adc_result(struct ads7924_data *data, if (chan->channel < 0 || chan->channel >= ADS7924_CHANNELS) return -EINVAL; + guard(mutex)(&data->lock); + if (data->conv_invalid) { int conv_time; @@ -227,9 +230,7 @@ static int ads7924_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: - mutex_lock(&data->lock); ret = ads7924_get_adc_result(data, chan, val); - mutex_unlock(&data->lock); if (ret < 0) return ret; |
