diff mbox series

[24/29] iio: adc: max1027: Switch to sparse friendly iio_device_claim/release_direct()

Message ID 20250217141630.897334-25-jic23@kernel.org (mailing list archive)
State New
Headers show
Series IIO: ADCs: Sparse friendly claim of direct mode | expand

Commit Message

Jonathan Cameron Feb. 17, 2025, 2:16 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/iio/adc/max1027.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Miquel Raynal Feb. 17, 2025, 3:40 p.m. UTC | #1
Hi Jonathan,

On 17/02/2025 at 14:16:24 GMT, Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> 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.

Ok, I didn't know.

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl
diff mbox series

Patch

diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c
index e6a47abc862f..7e736e77d8bb 100644
--- a/drivers/iio/adc/max1027.c
+++ b/drivers/iio/adc/max1027.c
@@ -378,12 +378,11 @@  static int max1027_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;
 
 		ret = max1027_read_single_value(indio_dev, chan, val);
-		iio_device_release_direct_mode(indio_dev);
+		iio_device_release_direct(indio_dev);
 		return ret;
 	case IIO_CHAN_INFO_SCALE:
 		switch (chan->type) {