]> Gentwo Git Trees - linux/.git/commitdiff
iio: imu: inv_mpu6050: Switch to sparse friendly iio_device_claim/release_direct()
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 31 Mar 2025 12:12:56 +0000 (13:12 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 22 Apr 2025 18:09:59 +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.

Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Link: https://patch.msgid.link/20250331121317.1694135-17-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c

index 5bcd5e7970468d0279aa81f104d1355d8ed3c648..b8656c02354a6a02624fba28a55778e76ef30496 100644 (file)
@@ -755,13 +755,12 @@ inv_mpu6050_read_raw(struct iio_dev *indio_dev,
 
        switch (mask) {
        case IIO_CHAN_INFO_RAW:
-               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);
                ret = inv_mpu6050_read_channel_data(indio_dev, chan, val);
                mutex_unlock(&st->lock);
-               iio_device_release_direct_mode(indio_dev);
+               iio_device_release_direct(indio_dev);
                return ret;
        case IIO_CHAN_INFO_SCALE:
                switch (chan->type) {
@@ -895,9 +894,8 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
         * we should only update scale when the chip is disabled, i.e.
         * not running
         */
-       result = iio_device_claim_direct_mode(indio_dev);
-       if (result)
-               return result;
+       if (!iio_device_claim_direct(indio_dev))
+               return -EBUSY;
 
        mutex_lock(&st->lock);
        result = pm_runtime_resume_and_get(pdev);
@@ -944,7 +942,7 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
        pm_runtime_put_autosuspend(pdev);
 error_write_raw_unlock:
        mutex_unlock(&st->lock);
-       iio_device_release_direct_mode(indio_dev);
+       iio_device_release_direct(indio_dev);
 
        return result;
 }