rust: devres: add DevresLt for ForLt-aware device resource access
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | rust: devres: add DevresLt for ForLt-aware device resource accessrust/ | +90 | 0 replies | |
| 2/3 | rust: pci: return DevresLt from Bar::into_devres()rust/ rust/ | +23 | 0 replies | |
| 3/3 | rust: io: mem: return DevresLt from IoMem/ExclusiveIoMem::into_devres()drivers/ rust/ | +42 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/3] rust: devres: add DevresLt for ForLt-aware device resource access
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/[email protected]/
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(-)
Signature · 1 line
2.54.0