iio: pressure: ms5611: Switch to sparse friendly iio_device_claim/release_direct()
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 31 Mar 2025 12:13:08 +0000 (13:13 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 22 Apr 2025 18:10:00 +0000 (19:10 +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>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Link: https://patch.msgid.link/20250331121317.1694135-29-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/pressure/ms5611_core.c

index 00c077b2a2a44a9b9665118733452c5e4c8d0298..bdac27bd5a5ddf159fdb8b2520a4549b05dc7de9 100644 (file)
@@ -308,7 +308,6 @@ static int ms5611_write_raw(struct iio_dev *indio_dev,
 {
        struct ms5611_state *st = iio_priv(indio_dev);
        const struct ms5611_osr *osr = NULL;
-       int ret;
 
        if (mask != IIO_CHAN_INFO_OVERSAMPLING_RATIO)
                return -EINVAL;
@@ -322,9 +321,8 @@ static int ms5611_write_raw(struct iio_dev *indio_dev,
        if (!osr)
                return -EINVAL;
 
-       ret = iio_device_claim_direct_mode(indio_dev);
-       if (ret)
-               return ret;
+       if (!iio_device_claim_direct(indio_dev))
+               return -EBUSY;
 
        mutex_lock(&st->lock);
 
@@ -334,7 +332,7 @@ static int ms5611_write_raw(struct iio_dev *indio_dev,
                st->pressure_osr = osr;
 
        mutex_unlock(&st->lock);
-       iio_device_release_direct_mode(indio_dev);
+       iio_device_release_direct(indio_dev);
 
        return 0;
 }