From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
To: Biren Pandya <birenpandya@gmail.com>
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] iio: accel: kxsd9: validate input before acquiring runtime PM in write_raw runtime PM in write_raw
Date: Mon, 20 Jul 2026 03:14:21 +0100 [thread overview]
Message-ID: <20260720031421.445f2216@jic23-huawei> (raw)
In-Reply-To: <20260714122520.3201-6-birenpandya@gmail.com>
On Tue, 14 Jul 2026 17:55:21 +0530
Biren Pandya <birenpandya@gmail.com> wrote:
> Currently, kxsd9_write_raw() acquires a runtime PM reference at the very
> top of the function, before checking if the requested mask or value are
> actually supported. This causes unnecessary hardware wakeups for invalid
> inputs.
>
> Refactor write_raw to validate inputs first. Additionally, modernize the
> PM runtime call by replacing pm_runtime_get_sync() with
> pm_runtime_resume_and_get() and adding the missing error check to
> prevent proceeding if power-on fails.
>
> Suggested-by: Jonathan Cameron <jic23@kernel.org>
> Signed-off-by: Biren Pandya <birenpandya@gmail.com>
Hi Biren,
For a series there should always be a cover letter.
This patch looks fine but you may want to take the approaches
I'll suggest in review of patch 2 and apply them here for consistency.
Thanks,
Jonathan
> ---
> drivers/iio/accel/kxsd9.c | 21 ++++++++++++---------
> 1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
> index 7ac885d94d7f4..b3acb20441d86 100644
> --- a/drivers/iio/accel/kxsd9.c
> +++ b/drivers/iio/accel/kxsd9.c
> @@ -139,18 +139,21 @@ static int kxsd9_write_raw(struct iio_dev *indio_dev,
> int val2,
> long mask)
> {
> - int ret = -EINVAL;
> struct kxsd9_state *st = iio_priv(indio_dev);
> + int ret;
>
> - pm_runtime_get_sync(st->dev);
> + if (mask != IIO_CHAN_INFO_SCALE)
> + return -EINVAL;
>
> - if (mask == IIO_CHAN_INFO_SCALE) {
> - /* Check no integer component */
> - if (val)
> - ret = -EINVAL;
> - else
> - ret = kxsd9_write_scale(indio_dev, val2);
> - }
> + /* Check no integer component */
> + if (val)
> + return -EINVAL;
> +
> + ret = pm_runtime_resume_and_get(st->dev);
> + if (ret < 0)
> + return ret;
> +
> + ret = kxsd9_write_scale(indio_dev, val2);
>
> pm_runtime_put_autosuspend(st->dev);
>
next prev parent reply other threads:[~2026-07-20 2:14 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 [this message]
2026-07-14 12:25 ` [PATCH 2/3] iio: accel: kxsd9: modernize runtime PM in read_raw Biren Pandya
2026-07-20 2:15 ` 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=20260720031421.445f2216@jic23-huawei \
--to=jonathan.cameron@oss.qualcomm.com \
--cc=andy@kernel.org \
--cc=birenpandya@gmail.com \
--cc=dlechner@baylibre.com \
--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