From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Hardik Phalet <hardik.phalet@pm.me>
Cc: gregkh@linuxfoundation.org, jic23@kernel.org, andy@kernel.org,
conor+dt@kernel.org, devicetree@vger.kernel.org,
dlechner@baylibre.com, krzk+dt@kernel.org,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-staging@lists.linux.dev, me@brighamcampbell.com,
nuno.sa@analog.com, robh@kernel.org, skhan@linuxfoundation.org,
Hardik Phalet <hardik.phalet@gmail.com>
Subject: Re: [PATCH v3 5/5] iio: magnetometer: qmc5883p: add PM support
Date: Mon, 20 Apr 2026 12:52:25 +0300 [thread overview]
Message-ID: <aeX3WUioap2KQCOp@ashevche-desk.local> (raw)
In-Reply-To: <20260420-qmc5883p-driver-v3-5-da1e97088f8b@pm.me>
On Sun, Apr 19, 2026 at 10:33:06PM +0000, Hardik Phalet wrote:
> Add runtime PM with a 2 s autosuspend delay. Per datasheet §6.2.1
> the chip continuously samples in MODE_NORMAL; putting it into
> MODE_SUSPEND when idle drops current from up to 1180 uA to ~22 uA
> (datasheet Table 2).
>
> Wrap qmc5883p_get_measure() and qmc5883p_write_raw() with
> pm_runtime_resume_and_get() / pm_runtime_put_autosuspend(), converting
> early returns to a goto so the put is always paired.
>
> System sleep is delegated to the runtime callbacks via
> SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume).
>
> A devm action is registered before devm_pm_runtime_enable() so that
> LIFO teardown on unbind runs pm_runtime_disable() first (freezing PM
> state) and then suspends the hardware via MODE_SUSPEND.
...
> + ret = pm_runtime_resume_and_get(data->dev);
> + if (ret < 0)
> + return ret;
Don't you want to use PM_RUNTIME_ACQUIRE_AUTOSUSPEND()?
...
> guard(mutex)(&data->mutex);
>
> - ret = regmap_field_write(data->rf.mode, QMC5883P_MODE_SUSPEND);
> + ret = pm_runtime_resume_and_get(data->dev);
> if (ret)
> return ret;
>
> + ret = regmap_field_write(data->rf.mode, QMC5883P_MODE_SUSPEND);
> + if (ret)
> + goto out;
No way, please, read what is written in the top of cleanup.h, also use
the advice I gave above.
> +out:
> + pm_runtime_put_autosuspend(data->dev);
> return ret;
> }
...
> +static const struct dev_pm_ops qmc5883p_dev_pm_ops = {
> + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
> + RUNTIME_PM_OPS(qmc5883p_runtime_suspend,
> + qmc5883p_runtime_resume, NULL)
Besides broken indentation, use proper macro from DEFINE_PM_*() family:
DEFINE_RUNTIME_DEV_PM_OPS().
> +};
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-04-20 9:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-19 22:32 [PATCH v3 0/5] iio: magnetometer: add driver for QST QMC5883P Hardik Phalet
2026-04-19 22:32 ` [PATCH v3 1/5] dt-bindings: vendor-prefixes: Add QST Corporation Hardik Phalet
2026-04-20 14:08 ` Krzysztof Kozlowski
2026-04-19 22:32 ` [PATCH v3 2/5] dt-bindings: iio: magnetometer: QSTCORP QMC5883P Hardik Phalet
2026-04-20 13:37 ` Jonathan Cameron
2026-04-20 14:10 ` Krzysztof Kozlowski
2026-04-19 22:32 ` [PATCH v3 3/5] iio: magnetometer: add driver for QST QMC5883P Hardik Phalet
2026-04-20 9:43 ` Andy Shevchenko
2026-04-20 14:22 ` Jonathan Cameron
2026-04-19 22:32 ` [PATCH v3 4/5] iio: magnetometer: qmc5883p: add oversampling ratio support Hardik Phalet
2026-04-20 9:45 ` Andy Shevchenko
2026-04-20 14:25 ` Jonathan Cameron
2026-04-19 22:33 ` [PATCH v3 5/5] iio: magnetometer: qmc5883p: add PM support Hardik Phalet
2026-04-20 9:52 ` Andy Shevchenko [this message]
2026-04-20 9:18 ` [PATCH v3 0/5] iio: magnetometer: add driver for QST QMC5883P Andy Shevchenko
2026-04-20 13:45 ` 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=aeX3WUioap2KQCOp@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=gregkh@linuxfoundation.org \
--cc=hardik.phalet@gmail.com \
--cc=hardik.phalet@pm.me \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=me@brighamcampbell.com \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
--cc=skhan@linuxfoundation.org \
/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