From: "Octávio Carneiro" <ocarneiro1@gmail.com>
To: marcelo.schmitt@analog.com, linux-iio@vger.kernel.org
Cc: ocarneiro1@gmail.com, fernandolimabusiness@gmail.com, eijiuchyama@usp.br
Subject: [PATCH] iio: adc: ad4000: Add iio_device_claim_direct() to protect buffered captures
Date: Wed, 7 May 2025 15:00:46 -0300 [thread overview]
Message-ID: <20250507180046.8515-1-ocarneiro1@gmail.com> (raw)
Add iio_device_claim_direct() to protect buffered captures. In
ad4000_write_raw_get_fmt, data reads are protected by the
function call to avoid possible errors caused by concurrent
access.
Signed-off-by: Fernando Lima <fernandolimabusiness@gmail.com>
Co-developed-by: Octávio Carneiro <ocarneiro1@gmail.com>
Signed-off-by: Octávio Carneiro <ocarneiro1@gmail.com>
Co-developed-by: Lucas Eiji <eijiuchyama@usp.br>
Signed-off-by: Lucas Eiji <eijiuchyama@usp.br>
---
drivers/iio/adc/ad4000.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/iio/adc/ad4000.c b/drivers/iio/adc/ad4000.c
index 4fe8dee48..55ceee6e9 100644
--- a/drivers/iio/adc/ad4000.c
+++ b/drivers/iio/adc/ad4000.c
@@ -583,6 +583,9 @@ static int ad4000_write_raw_get_fmt(struct iio_dev *indio_dev,
{
switch (mask) {
case IIO_CHAN_INFO_SCALE:
+ if (!iio_device_claim_direct(indio_dev))
+ return -EBUSY;
+ iio_device_release_direct(indio_dev);
return IIO_VAL_INT_PLUS_NANO;
default:
return IIO_VAL_INT_PLUS_MICRO;
--
2.34.1
next reply other threads:[~2025-05-07 18:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-07 18:00 Octávio Carneiro [this message]
2025-05-08 5:34 ` [PATCH] iio: adc: ad4000: Add iio_device_claim_direct() to protect buffered captures Marcelo Schmitt
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=20250507180046.8515-1-ocarneiro1@gmail.com \
--to=ocarneiro1@gmail.com \
--cc=eijiuchyama@usp.br \
--cc=fernandolimabusiness@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=marcelo.schmitt@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