]> git.baikalelectronics.ru Git - kernel.git/commitdiff
iio: adc: max1027: unlock on error path in max1027_read_single_value()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 7 Jul 2022 14:54:45 +0000 (17:54 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 19 Jul 2022 08:30:05 +0000 (09:30 +0100)
If max1027_wait_eoc() fails then call iio_device_release_direct_mode()
before returning.

Fixes: bbdb86306b29 ("iio: adc: max1027: Introduce an end of conversion helper")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YsbztVuAXnau2cIZ@kili
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/max1027.c

index b725d012625c16a7900d278a18a2e7c5dd277dbe..136fcf753837c83ec7c9e67b6732ce3f7c152666 100644 (file)
@@ -349,8 +349,7 @@ static int max1027_read_single_value(struct iio_dev *indio_dev,
        if (ret < 0) {
                dev_err(&indio_dev->dev,
                        "Failed to configure conversion register\n");
-               iio_device_release_direct_mode(indio_dev);
-               return ret;
+               goto release;
        }
 
        /*
@@ -360,11 +359,12 @@ static int max1027_read_single_value(struct iio_dev *indio_dev,
         */
        ret = max1027_wait_eoc(indio_dev);
        if (ret)
-               return ret;
+               goto release;
 
        /* Read result */
        ret = spi_read(st->spi, st->buffer, (chan->type == IIO_TEMP) ? 4 : 2);
 
+release:
        iio_device_release_direct_mode(indio_dev);
 
        if (ret < 0)