iio: light: apds9306: Switch to sparse friendly iio_device_claim/release_direct()
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 9 Mar 2025 17:06:16 +0000 (17:06 +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.

Acked-by: Subhajit Ghosh <subhajit.ghosh@tweaklogic.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-2-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/light/apds9306.c

index 5ed7e17f49e76206609aba83c85e8144c536d17d..e9b237de180a97d6541e2a491ed45381123d4945 100644 (file)
@@ -831,11 +831,10 @@ static int apds9306_read_raw(struct iio_dev *indio_dev,
                 * Changing device parameters during adc operation, resets
                 * the ADC which has to avoided.
                 */
-               ret = iio_device_claim_direct_mode(indio_dev);
-               if (ret)
-                       return ret;
+               if (!iio_device_claim_direct(indio_dev))
+                       return -EBUSY;
                ret = apds9306_read_data(data, val, reg);
-               iio_device_release_direct_mode(indio_dev);
+               iio_device_release_direct(indio_dev);
                if (ret)
                        return ret;