[PATCH 2/3] iio: accel: kxsd9: modernize runtime PM in read_raw
From: Biren Pandya
Date: Tue Jul 14 2026 - 08:27:55 EST
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@xxxxxxxxxx>
Signed-off-by: Biren Pandya <birenpandya@xxxxxxxxx>
---
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)