public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: frequency: ad9523: check return value of ad9523_io_update()
@ 2026-03-17 23:25 Bhargav Joshi
  2026-03-18  8:10 ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Bhargav Joshi @ 2026-03-17 23:25 UTC (permalink / raw)
  To: linux-iio, lars, Michael.Hennerich, jic23
  Cc: dlechner, nuno.sa, andy, rougueprince47

Several functions in ad9523 driver calls ad9523_io_update() to apply
register changes but fail to check its return value.

If the function fails, driver silently ignore the error and returns
success. This results in user-space assuming register changes even if
they are failed.

Fix this by properly catching and returning the error code from
ad9523_io_update() in ad9523_sync(), ad9523_write_raw(), and
ad9523_reg_access()

Signed-off-by: Bhargav Joshi <rougueprince47@gmail.com>
---
 drivers/iio/frequency/ad9523.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index 63c485e9e44c..66bba37fb199 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -495,7 +495,10 @@ static int ad9523_sync(struct iio_dev *indio_dev)
 	if (ret < 0)
 		return ret;
 
-	ad9523_io_update(indio_dev);
+	ret = ad9523_io_update(indio_dev);
+	if (ret < 0)
+		return ret;
+
 	tmp &= ~AD9523_STATUS_SIGNALS_SYNC_MAN_CTRL;
 
 	ret = ad9523_write(indio_dev, AD9523_STATUS_SIGNALS, tmp);
@@ -716,7 +719,7 @@ static int ad9523_write_raw(struct iio_dev *indio_dev,
 	if (ret < 0)
 		goto out;
 
-	ad9523_io_update(indio_dev);
+	ret = ad9523_io_update(indio_dev);
 out:
 	mutex_unlock(&st->lock);
 	return ret;
@@ -732,7 +735,9 @@ static int ad9523_reg_access(struct iio_dev *indio_dev,
 	mutex_lock(&st->lock);
 	if (readval == NULL) {
 		ret = ad9523_write(indio_dev, reg | AD9523_R1B, writeval);
-		ad9523_io_update(indio_dev);
+		if (ret < 0)
+			goto out_unlock;
+		ret = ad9523_io_update(indio_dev);
 	} else {
 		ret = ad9523_read(indio_dev, reg | AD9523_R1B);
 		if (ret < 0)
-- 
2.53.0


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

end of thread, other threads:[~2026-03-18 18:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-17 23:25 [PATCH] iio: frequency: ad9523: check return value of ad9523_io_update() Bhargav Joshi
2026-03-18  8:10 ` Andy Shevchenko
2026-03-18 15:29   ` Bhargav Joshi
2026-03-18 18:22     ` Andy Shevchenko

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