From: Danilo Krummrich <dakr@kernel.org>
To: gregkh@linuxfoundation.org, rafael@kernel.org,
acourbot@nvidia.com, aliceryhl@google.com,
david.m.ertman@intel.com, ira.weiny@intel.com, leon@kernel.org,
viresh.kumar@linaro.org, m.wilczynski@samsung.com,
ukleinek@kernel.org, bhelgaas@google.com, kwilczynski@kernel.org,
abdiel.janulgue@gmail.com, robin.murphy@arm.com,
markus.probst@posteo.de, ojeda@kernel.org, boqun@kernel.org,
gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org,
a.hindborg@kernel.org, tmgross@umich.edu, igor.korotin@linux.dev,
daniel.almeida@collabora.com
Cc: driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org,
linux-pm@vger.kernel.org, linux-pwm@vger.kernel.org,
linux-pci@vger.kernel.org, rust-for-linux@vger.kernel.org,
Danilo Krummrich <dakr@kernel.org>
Subject: [PATCH 0/3] rust: devres: add DevresLt for ForLt-aware device resource access
Date: Wed, 6 May 2026 23:58:32 +0200 [thread overview]
Message-ID: <20260506220012.855173-1-dakr@kernel.org> (raw)
Devres<T> stores resources as T and hands out &'bound T from its access
methods. For lifetime-parameterized types like Bar<'bound, SIZE> that
are transmuted to 'static for storage, the synthetic 'static leaks to
callers -- any method on the stored type that surfaces its lifetime
parameter would yield a &'static reference, which is unsound.
This series adds DevresLt<F: ForLt>, a thin wrapper around
Devres<F::Of<'static>> that applies ForLt::cast_ref in all access paths
to shorten the stored 'static back to the caller's borrow lifetime.
Devres<T: Send> remains unchanged for static resource types.
Also implement ForLt for Bar, IoMem and ExclusiveIoMem, and their
into_devres() methods to return DevresLt instead of plain Devres.
Provide convenience type aliases DevresBar, DevresIoMem and
DevresExclusiveIoMem.
This series depends on [1].
[1] https://lore.kernel.org/driver-core/20260506215113.851360-1-dakr@kernel.org/
Danilo Krummrich (3):
rust: devres: add DevresLt for ForLt-aware device resource access
rust: pci: return DevresLt from Bar::into_devres()
rust: io: mem: return DevresLt from
IoMem/ExclusiveIoMem::into_devres()
drivers/pwm/pwm_th1520.rs | 5 +-
rust/kernel/devres.rs | 97 ++++++++++++++++++++++++++++++++++++---
rust/kernel/io/mem.rs | 55 ++++++++++++++++------
rust/kernel/pci.rs | 1 +
rust/kernel/pci/io.rs | 30 ++++++++----
5 files changed, 155 insertions(+), 33 deletions(-)
--
2.54.0
next reply other threads:[~2026-05-06 22:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 21:58 Danilo Krummrich [this message]
2026-05-06 21:58 ` [PATCH 1/3] rust: devres: add DevresLt for ForLt-aware device resource access Danilo Krummrich
2026-05-06 21:58 ` [PATCH 2/3] rust: pci: return DevresLt from Bar::into_devres() Danilo Krummrich
2026-05-06 21:58 ` [PATCH 3/3] rust: io: mem: return DevresLt from IoMem/ExclusiveIoMem::into_devres() Danilo Krummrich
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=20260506220012.855173-1-dakr@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=abdiel.janulgue@gmail.com \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=david.m.ertman@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=igor.korotin@linux.dev \
--cc=ira.weiny@intel.com \
--cc=kwilczynski@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=m.wilczynski@samsung.com \
--cc=markus.probst@posteo.de \
--cc=nova-gpu@lists.linux.dev \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=robin.murphy@arm.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=ukleinek@kernel.org \
--cc=viresh.kumar@linaro.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