]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
iio: adc: mxs-lradc: Switch to sparse friendly iio_device_claim/release_direct()
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 9 Mar 2025 16:58:18 +0000 (16:58 +0000)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 22 Apr 2025 18:09:55 +0000 (19:09 +0100)
These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309165819.1346684-8-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/mxs-lradc-adc.c

index 152cbe265e1a2ea9acf934f3a9ccef2da2628c40..8f1e6acea53ba19faa2cd6e0a90d39398d6d2e95 100644 (file)
@@ -141,9 +141,8 @@ static int mxs_lradc_adc_read_single(struct iio_dev *iio_dev, int chan,
         * the same time, yet the code becomes horribly complicated. Therefore I
         * applied KISS principle here.
         */
-       ret = iio_device_claim_direct_mode(iio_dev);
-       if (ret)
-               return ret;
+       if (!iio_device_claim_direct(iio_dev))
+               return -EBUSY;
 
        reinit_completion(&adc->completion);
 
@@ -192,7 +191,7 @@ err:
        writel(LRADC_CTRL1_LRADC_IRQ_EN(0),
               adc->base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR);
 
-       iio_device_release_direct_mode(iio_dev);
+       iio_device_release_direct(iio_dev);
 
        return ret;
 }
@@ -275,9 +274,8 @@ static int mxs_lradc_adc_write_raw(struct iio_dev *iio_dev,
                        adc->scale_avail[chan->channel];
        int ret;
 
-       ret = iio_device_claim_direct_mode(iio_dev);
-       if (ret)
-               return ret;
+       if (!iio_device_claim_direct(iio_dev))
+               return -EBUSY;
 
        switch (m) {
        case IIO_CHAN_INFO_SCALE:
@@ -300,7 +298,7 @@ static int mxs_lradc_adc_write_raw(struct iio_dev *iio_dev,
                break;
        }
 
-       iio_device_release_direct_mode(iio_dev);
+       iio_device_release_direct(iio_dev);
 
        return ret;
 }