diff options
author | Nuno Sa <nuno.sa@analog.com> | 2024-06-18 16:32:05 +0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2024-06-25 23:04:49 +0300 |
commit | d305b7f34ee11c4901b8da150b641bcffbd3e951 (patch) | |
tree | f25383301822454b415788f2b5ffc939ec1bb035 /drivers/iio | |
parent | d80d4a3ce3aa3b0d8ac6966cb15f79d0c4a542e2 (diff) | |
download | linux-d305b7f34ee11c4901b8da150b641bcffbd3e951.tar.xz |
iio: imu: adis: move to the cleanup magic
This makes locking and handling error paths simpler.
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240618-dev-iio-adis-cleanup-v1-2-bd93ce7845c7@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/imu/adis.c | 11 | ||||
-rw-r--r-- | drivers/iio/imu/adis_buffer.c | 8 |
2 files changed, 6 insertions, 13 deletions
diff --git a/drivers/iio/imu/adis.c b/drivers/iio/imu/adis.c index 495caf4ce87a..876848b42f69 100644 --- a/drivers/iio/imu/adis.c +++ b/drivers/iio/imu/adis.c @@ -466,17 +466,17 @@ int adis_single_conversion(struct iio_dev *indio_dev, unsigned int uval; int ret; - mutex_lock(&adis->state_lock); + guard(mutex)(&adis->state_lock); ret = __adis_read_reg(adis, chan->address, &uval, chan->scan_type.storagebits / 8); if (ret) - goto err_unlock; + return ret; if (uval & error_mask) { ret = __adis_check_status(adis); if (ret) - goto err_unlock; + return ret; } if (chan->scan_type.sign == 's') @@ -484,10 +484,7 @@ int adis_single_conversion(struct iio_dev *indio_dev, else *val = uval & ((1 << chan->scan_type.realbits) - 1); - ret = IIO_VAL_INT; -err_unlock: - mutex_unlock(&adis->state_lock); - return ret; + return IIO_VAL_INT; } EXPORT_SYMBOL_NS_GPL(adis_single_conversion, IIO_ADISLIB); diff --git a/drivers/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c index 5bde698cce18..b7c1cc04492a 100644 --- a/drivers/iio/imu/adis_buffer.c +++ b/drivers/iio/imu/adis_buffer.c @@ -130,24 +130,20 @@ static int adis_paging_trigger_handler(struct adis *adis) { int ret; - mutex_lock(&adis->state_lock); + guard(mutex)(&adis->state_lock); if (adis->current_page != 0) { adis->tx[0] = ADIS_WRITE_REG(ADIS_REG_PAGE_ID); adis->tx[1] = 0; ret = spi_write(adis->spi, adis->tx, 2); if (ret) { dev_err(&adis->spi->dev, "Failed to change device page: %d\n", ret); - mutex_unlock(&adis->state_lock); return ret; } adis->current_page = 0; } - ret = spi_sync(adis->spi, &adis->msg); - mutex_unlock(&adis->state_lock); - - return ret; + return spi_sync(adis->spi, &adis->msg); } static irqreturn_t adis_trigger_handler(int irq, void *p) |