Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: adc: ad4000: Add iio_device_claim_direct() to protect buffered captures
@ 2025-05-07 18:00 Octávio Carneiro
  2025-05-08  5:34 ` Marcelo Schmitt
  0 siblings, 1 reply; 2+ messages in thread
From: Octávio Carneiro @ 2025-05-07 18:00 UTC (permalink / raw)
  To: marcelo.schmitt, linux-iio; +Cc: ocarneiro1, fernandolimabusiness, eijiuchyama

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-05-08  5:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-07 18:00 [PATCH] iio: adc: ad4000: Add iio_device_claim_direct() to protect buffered captures Octávio Carneiro
2025-05-08  5:34 ` Marcelo Schmitt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox