Re: [PATCH v2 1/3] rust: add runtime PM support
Alice Ryhl <[email protected]> Tue, 4 Aug 2026 08:06:07 +0000
| Newsgroups | org.kernel.vger.rust-for-linux,dev.linux.lists.driver-core,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pm |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Jul 21, 2026 at 05:34:02PM +0200, Beata Michalska wrote:
> diff --git a/rust/helpers/pm_runtime.c b/rust/helpers/pm_runtime.c
> new file mode 100644
> index 000000000000..d0d71fcb0097
> --- /dev/null
> +++ b/rust/helpers/pm_runtime.c
> @@ -0,0 +1,44 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <linux/pm_runtime.h>
> +
> +__rust_helper void rust_helper_pm_runtime_get_noresume(struct device *dev)
> +{
> + pm_runtime_get_noresume(dev);
> +}
> +
> +__rust_helper void rust_helper_pm_runtime_put_noidle(struct device *dev)
> +{
> + pm_runtime_put_noidle(dev);
> +}
Should this file be wrapped in `#ifdef !CONFIG_PM` or similar?
> +/// Runtime Power Management modes that determine how a particular PM
> +/// transition is to be carried out.
> +/// Corresponds to C Runtime PM flag argument bits:
> +/// - `RPM_ASYNC`
> +/// - `RPM_NOWAIT`
> +/// - `RPM_GET_PUT`
> +/// - `RPM_AUTO`
> +#[derive(Clone, Copy, PartialEq, Eq, Debug)]
> +struct Mode(u32);
Nit: we have a macro for bit flags.
See for example:
https://lore.kernel.org/rust-for-linux/[email protected]/
> +#[cfg(CONFIG_PM)]
> +impl Request {
> + ...
> +}
> +
> +#[cfg(not(CONFIG_PM))]
> +impl Request {
> + ...
> +}
Doesn't your rust/helpers file already handle these for you? The methods
exist as stubs in the C header on not(CONFIG_PM), I think?
Alice