iio: light: gp2ap020a00f: Switch to sparse friendly iio_device_claim/release_direct()

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/20250309170633.1347476-3-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
Jonathan Cameron
2025-03-09 17:06:17 +00:00
parent 354eedf008
commit 403443117b

View File

@@ -1283,12 +1283,11 @@ static int gp2ap020a00f_read_raw(struct iio_dev *indio_dev,
int err = -EINVAL;
if (mask == IIO_CHAN_INFO_RAW) {
err = iio_device_claim_direct_mode(indio_dev);
if (err)
return err;
if (!iio_device_claim_direct(indio_dev))
return -EBUSY;
err = gp2ap020a00f_read_channel(data, chan, val);
iio_device_release_direct_mode(indio_dev);
iio_device_release_direct(indio_dev);
}
return err < 0 ? err : IIO_VAL_INT;
}