From: Jonathan Cameron <jic23@kernel.org>
To: "Frank Li" <Frank.Li@nxp.com>,
"Marek Vasut" <marek.vasut+renesas@gmail.com>,
linux-iio@vger.kernel.org, "Nuno Sá" <noname.nuno@gmail.com>
Cc: "Marek Vasut" <marex@denx.de>,
"Mike Looijmans" <mike.looijmans@topic.nl>,
"Nuno Sá" <nuno.sa@analog.com>,
"David Lechner" <dlechner@baylibre.com>,
"Jonathan Cameron" <Jonathan.Cameron@huawei.com>
Subject: [PATCH v2 7/8] iio: adc: mxs-lradc: Switch to sparse friendly iio_device_claim/release_direct()
Date: Sun, 9 Mar 2025 16:58:18 +0000 [thread overview]
Message-ID: <20250309165819.1346684-8-jic23@kernel.org> (raw)
In-Reply-To: <20250309165819.1346684-1-jic23@kernel.org>
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>
---
drivers/iio/adc/mxs-lradc-adc.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/adc/mxs-lradc-adc.c b/drivers/iio/adc/mxs-lradc-adc.c
index 152cbe265e1a..8f1e6acea53b 100644
--- a/drivers/iio/adc/mxs-lradc-adc.c
+++ b/drivers/iio/adc/mxs-lradc-adc.c
@@ -141,9 +141,8 @@ static int mxs_lradc_adc_read_single(struct iio_dev *iio_dev, int chan,
* the same time, yet the code becomes horribly complicated. Therefore I
* applied KISS principle here.
*/
- ret = iio_device_claim_direct_mode(iio_dev);
- if (ret)
- return ret;
+ if (!iio_device_claim_direct(iio_dev))
+ return -EBUSY;
reinit_completion(&adc->completion);
@@ -192,7 +191,7 @@ static int mxs_lradc_adc_read_single(struct iio_dev *iio_dev, int chan,
writel(LRADC_CTRL1_LRADC_IRQ_EN(0),
adc->base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR);
- iio_device_release_direct_mode(iio_dev);
+ iio_device_release_direct(iio_dev);
return ret;
}
@@ -275,9 +274,8 @@ static int mxs_lradc_adc_write_raw(struct iio_dev *iio_dev,
adc->scale_avail[chan->channel];
int ret;
- ret = iio_device_claim_direct_mode(iio_dev);
- if (ret)
- return ret;
+ if (!iio_device_claim_direct(iio_dev))
+ return -EBUSY;
switch (m) {
case IIO_CHAN_INFO_SCALE:
@@ -300,7 +298,7 @@ static int mxs_lradc_adc_write_raw(struct iio_dev *iio_dev,
break;
}
- iio_device_release_direct_mode(iio_dev);
+ iio_device_release_direct(iio_dev);
return ret;
}
--
2.48.1
next prev parent reply other threads:[~2025-03-09 16:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-09 16:58 [PATCH v2 0/8] IIO: ADCs: Sparse friendly claim of direct mode Jonathan Cameron
2025-03-09 16:58 ` [PATCH v2 1/8] iio: adc: vf610: Move claim of direct mode to caller of vf610_read_sample and use guard(mutex) Jonathan Cameron
2025-03-09 16:58 ` [PATCH v2 2/8] iio: adc: vf610: Switch to sparse friendly iio_device_claim/release_direct() Jonathan Cameron
2025-03-09 16:58 ` [PATCH v2 3/8] iio: adc: ti-ads1100: Use guard(mutex) to allow direct returns Jonathan Cameron
2025-03-09 16:58 ` [PATCH v2 4/8] iio: adc: ti-ads1100: Switch to sparse friendly iio_device_claim/release_direct() Jonathan Cameron
2025-03-09 16:58 ` [PATCH v2 5/8] iio: adc: ti-ads1015: Use guard(mutex) and factor out code for INFO_RAW Jonathan Cameron
2025-03-10 23:18 ` David Lechner
2025-03-31 11:32 ` Jonathan Cameron
2025-03-09 16:58 ` [PATCH v2 6/8] iio: adc: ti-ads1015: Switch to sparse friendly iio_device_claim/release_direct() Jonathan Cameron
2025-03-09 16:58 ` Jonathan Cameron [this message]
2025-03-09 16:58 ` [PATCH v2 8/8] iio: adc: rcar: " Jonathan Cameron
2025-03-10 23:21 ` [PATCH v2 0/8] IIO: ADCs: Sparse friendly claim of direct mode David Lechner
2025-03-31 11:33 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250309165819.1346684-8-jic23@kernel.org \
--to=jic23@kernel.org \
--cc=Frank.Li@nxp.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=dlechner@baylibre.com \
--cc=linux-iio@vger.kernel.org \
--cc=marek.vasut+renesas@gmail.com \
--cc=marex@denx.de \
--cc=mike.looijmans@topic.nl \
--cc=noname.nuno@gmail.com \
--cc=nuno.sa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox