Rust for Linux List
 help / color / mirror / Atom feed
* [PATCH 0/4] rust: pin-init: merge `__init` and `__pinned_init`
@ 2026-07-22 18:50 Gary Guo
  2026-07-22 18:50 ` [PATCH 1/4] rust: pin-init: merge `__pinned_init` and `__init` Gary Guo
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Gary Guo @ 2026-07-22 18:50 UTC (permalink / raw)
  To: Benno Lossin, Miguel Ojeda, Boqun Feng, Björn Roy Baron,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
	Onur Özkan
  Cc: rust-for-linux, linux-kernel, Gary Guo

Currently we have `PinInit::__pinned_init` and `Init::__init` which has
slightly different safety requirement but are required to do the same
thing. Instead of having to duplicate impl everywhere, it's simpler to just
use `Init` as a marker trait that cancels out the pinning requirement on
`PinInit::__pinned_init`. This also simplifies code (and shorten the symbol
name) so `__init` can always be used.

Note that to pull off this change it needs a stage approach. The plan is:
* Patch 1 (the `__pinned_init` and `__init` merge) is to be taken this
  cycle through pin-init tree; this preserves the `__pinned_init` method as
  an alias for compatibility.
* Patch 2 can be taken via driver-core this cycle.
* Patch 3 (tree-wide changes) to be taken next cycle. I can split this
  further up next cycle so this can be routed via various subsystems.
* Patch 4 (removal of `__pinned_init`) is to be taken via pin-init two
  cycles after.

---
This might be an opportunity to rethink about the API. IIRC we use `__init`
initially to avoid conflicts because we have the blanket impl on `T` and
`Result<T, E>`.

Maybe we should get rid of the underscores and name it something more
proper, like `init_ptr`, or maybe add an extension trait to raw pointers
type so you can do

    unsafe { raw_ptr.init(something_that_impls_pin_init) }

?

To: Benno Lossin <lossin@kernel.org>
To: Miguel Ojeda <ojeda@kernel.org>
To: Boqun Feng <boqun@kernel.org>
To: Björn Roy Baron <bjorn3_gh@protonmail.com>
To: Andreas Hindborg <a.hindborg@kernel.org>
To: Alice Ryhl <aliceryhl@google.com>
To: Trevor Gross <tmgross@umich.edu>
To: Danilo Krummrich <dakr@kernel.org>
To: Daniel Almeida <daniel.almeida@collabora.com>
To: Tamir Duberstein <tamird@kernel.org>
To: Alexandre Courbot <acourbot@nvidia.com>
To: Onur Özkan <work@onurozkan.dev>
Cc: rust-for-linux@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Gary Guo <gary@garyguo.net>

---
Gary Guo (4):
      rust: pin-init: merge `__pinned_init` and `__init`
      rust: devres: use `cast_pin_init` instead of manual reimplementation
      rust: treewide: replace `__pinned_init` with `__init`
      rust: pin-init: remove `__pinned_init` method for `cfg(kernel)`

 rust/kernel/alloc/kbox.rs             |   6 +-
 rust/kernel/devres.rs                 |   6 +-
 rust/kernel/drm/device.rs             |   2 +-
 rust/kernel/drm/gpuvm/va.rs           |   2 +-
 rust/kernel/drm/gpuvm/vm_bo.rs        |   2 +-
 rust/kernel/init.rs                   |  10 +--
 rust/kernel/pwm.rs                    |   2 +-
 rust/kernel/sync/arc.rs               |   4 +-
 rust/kernel/types.rs                  |   2 +-
 rust/macros/module.rs                 |   2 +-
 rust/pin-init/examples/mutex.rs       |   2 +-
 rust/pin-init/examples/static_init.rs |   9 +--
 rust/pin-init/src/__internal.rs       |   8 +-
 rust/pin-init/src/alloc.rs            |   6 +-
 rust/pin-init/src/lib.rs              | 147 ++++++++++++++--------------------
 15 files changed, 85 insertions(+), 125 deletions(-)
---
base-commit: b4515cf4156356e8f4fe6e0fdc17f59adab9772f
change-id: 20260722-merge-init-3ed98519ec7f

Best regards,
--  
Gary Guo <gary@garyguo.net>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-22 18:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-22 18:50 [PATCH 0/4] rust: pin-init: merge `__init` and `__pinned_init` Gary Guo
2026-07-22 18:50 ` [PATCH 1/4] rust: pin-init: merge `__pinned_init` and `__init` Gary Guo
2026-07-22 18:50 ` [PATCH 2/4] rust: devres: use `cast_pin_init` instead of manual reimplementation Gary Guo
2026-07-22 18:50 ` [PATCH 3/4] rust: treewide: replace `__pinned_init` with `__init` Gary Guo
2026-07-22 18:50 ` [PATCH 4/4] rust: pin-init: remove `__pinned_init` method for `cfg(kernel)` Gary Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox