[PATCH 0/4] rust: pin-init: merge `__init` and `__pinned_init`

Gary Guo <[email protected]>
Newsgroups org.kernel.vger.rust-for-linux,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
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 <[email protected]>
To: Miguel Ojeda <[email protected]>
To: Boqun Feng <[email protected]>
To: Björn Roy Baron <[email protected]>
To: Andreas Hindborg <[email protected]>
To: Alice Ryhl <[email protected]>
To: Trevor Gross <[email protected]>
To: Danilo Krummrich <[email protected]>
To: Daniel Almeida <[email protected]>
To: Tamir Duberstein <[email protected]>
To: Alexandre Courbot <[email protected]>
To: Onur Özkan <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Gary Guo <[email protected]>

---
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 <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.