public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Bhargav Joshi <rougueprince47@gmail.com>
To: linux-iio@vger.kernel.org, lars@metafoo.de,
	Michael.Hennerich@analog.com, jic23@kernel.org
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	rougueprince47@gmail.com
Subject: [PATCH] iio: frequency: ad9523: check return value of ad9523_io_update()
Date: Wed, 18 Mar 2026 04:55:52 +0530	[thread overview]
Message-ID: <20260317232552.28485-1-rougueprince47@gmail.com> (raw)

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


             reply	other threads:[~2026-03-17 23:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-17 23:25 Bhargav Joshi [this message]
2026-03-18  8:10 ` [PATCH] iio: frequency: ad9523: check return value of ad9523_io_update() Andy Shevchenko
2026-03-18 15:29   ` Bhargav Joshi
2026-03-18 18:22     ` Andy Shevchenko

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=20260317232552.28485-1-rougueprince47@gmail.com \
    --to=rougueprince47@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --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