Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: adc: ti-ads1119: Prevent concurrent access during
@ 2025-04-19 23:23 nattan
  2025-04-20 16:07 ` João Paulo Gonçalves
  0 siblings, 1 reply; 8+ messages in thread
From: nattan @ 2025-04-19 23:23 UTC (permalink / raw)
  To: francesco, jpaulo.silvagoncalves, jic23
  Cc: lucasantonio.santos, Nattan Ferreira, linux-iio

From: Nattan Ferreira <nattanferreira58@gmail.com>

Use iio_device_claim_direct() to protect register access via debugfs
from conflicting with buffered capture modes. This prevents data
corruption and ensures correct device operation when users access
registers while streaming data.

Signed-off-by: Nattan Ferreira <nattanferreira58@gmail.com>
Co-developed-by: Lucas Antonio <lucasantonio.santos@usp.br>
Signed-off-by: Lucas Antonio <lucasantonio.santos@usp.br>
---
 drivers/iio/adc/ti-ads1119.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/iio/adc/ti-ads1119.c b/drivers/iio/adc/ti-ads1119.c
index f120e7e21..273fb8e35 100644
--- a/drivers/iio/adc/ti-ads1119.c
+++ b/drivers/iio/adc/ti-ads1119.c
@@ -405,6 +405,9 @@ static int ads1119_debugfs_reg_access(struct iio_dev *indio_dev,
 	struct ads1119_state *st = iio_priv(indio_dev);
 	int ret;
 
+	if (!iio_device_claim_direct(indio_dev))
+		return -EBUSY;
+
 	if (reg > ADS1119_REG_STATUS)
 		return -EINVAL;
 
@@ -421,6 +424,8 @@ static int ads1119_debugfs_reg_access(struct iio_dev *indio_dev,
 	if (reg > ADS1119_REG_CONFIG)
 		return -EINVAL;
 
+	iio_device_release_direct(indio_dev);
+
 	return i2c_smbus_write_byte_data(st->client, ADS1119_CMD_WREG,
 					 writeval);
 }
-- 
2.34.1


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

end of thread, other threads:[~2025-04-25  8:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-19 23:23 [PATCH] iio: adc: ti-ads1119: Prevent concurrent access during nattan
2025-04-20 16:07 ` João Paulo Gonçalves
2025-04-20 21:17   ` Francesco Dolcini
2025-04-21 13:23     ` Jonathan Cameron
2025-04-21 14:42       ` Marcelo Schmitt
2025-04-25  8:10         ` Jonathan Cameron
2025-04-22 18:04     ` Nattan Ferreira
2025-04-25  8:14       ` Jonathan Cameron

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