From: Biren Pandya <birenpandya@gmail.com>
To: jic23@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com,
andy@kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Biren Pandya <birenpandya@gmail.com>
Subject: [PATCH 2/3] iio: accel: kxsd9: modernize runtime PM in read_raw
Date: Tue, 14 Jul 2026 17:55:22 +0530 [thread overview]
Message-ID: <20260714122520.3201-7-birenpandya@gmail.com> (raw)
In-Reply-To: <20260714122520.3201-5-birenpandya@gmail.com>
Replace the legacy pm_runtime_get_sync() call with the modern
pm_runtime_resume_and_get() in kxsd9_read_raw().
If the resume fails, we now correctly abort the read instead of
carrying on and reading garbage data from the sleeping hardware.
Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Biren Pandya <birenpandya@gmail.com>
---
drivers/iio/accel/kxsd9.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
index b3acb20441d86..680d43135e617 100644
--- a/drivers/iio/accel/kxsd9.c
+++ b/drivers/iio/accel/kxsd9.c
@@ -164,13 +164,15 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{
- int ret = -EINVAL;
struct kxsd9_state *st = iio_priv(indio_dev);
unsigned int regval;
__be16 raw_val;
u16 nval;
+ int ret;
- pm_runtime_get_sync(st->dev);
+ ret = pm_runtime_resume_and_get(st->dev);
+ if (ret < 0)
+ return ret;
switch (mask) {
case IIO_CHAN_INFO_RAW:
@@ -199,6 +201,9 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev,
*val2 = kxsd9_micro_scales[regval & KXSD9_CTRL_C_FS_MASK];
ret = IIO_VAL_INT_PLUS_MICRO;
break;
+ default:
+ ret = -EINVAL;
+ break;
}
error_ret:
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2026-07-14 12:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260714122520.3201-5-birenpandya@gmail.com>
2026-07-14 12:25 ` [PATCH 1/3] iio: accel: kxsd9: validate input before acquiring runtime PM in write_raw runtime PM in write_raw Biren Pandya
2026-07-20 2:14 ` Jonathan Cameron
2026-07-14 12:25 ` Biren Pandya [this message]
2026-07-20 2:15 ` [PATCH 2/3] iio: accel: kxsd9: modernize runtime PM in read_raw Jonathan Cameron
2026-07-14 12:25 ` [PATCH 3/3] iio: accel: kxsd9: use dev_err_probe() Biren Pandya
2026-07-20 2:18 ` Jonathan Cameron
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=20260714122520.3201-7-birenpandya@gmail.com \
--to=birenpandya@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@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