rust: make pin-init its own crate

Rename relative paths inside of the crate to still refer to the same
items, also rename paths inside of the kernel crate and adjust the build
system to build the crate.

[ Remove the `expect` (and thus the `lint_reasons` feature) since
  the tree now uses `quote!` from `rust/macros/export.rs`. Remove the
  `TokenStream` import removal, since it is now used as well.

  In addition, temporarily (i.e. just for this commit) use an `--extern
  force:alloc` to prevent an unknown `new_uninit` error in the `rustdoc`
  target. For context, please see a similar case in:

      https://lore.kernel.org/lkml/20240422090644.525520-1-ojeda@kernel.org/

  And adjusted the message above. - Miguel ]

Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Fiona Behrens <me@kloenk.dev>
Tested-by: Andreas Hindborg <a.hindborg@kernel.org>
Link: https://lore.kernel.org/r/20250308110339.2997091-16-benno.lossin@proton.me
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
Benno Lossin
2025-03-08 11:05:09 +00:00
committed by Miguel Ojeda
parent d7659acca7
commit dbd5058ba6
28 changed files with 164 additions and 153 deletions

View File

@@ -50,11 +50,7 @@ pub mod faux;
#[cfg(CONFIG_RUST_FW_LOADER_ABSTRACTIONS)]
pub mod firmware;
pub mod fs;
#[path = "../pin-init/src/lib.rs"]
pub mod init;
// momentarily use the name `init_ext` and set the path manually
#[path = "init.rs"]
pub mod init_ext;
pub mod io;
pub mod ioctl;
pub mod jump_label;
@@ -116,11 +112,11 @@ pub trait InPlaceModule: Sync + Send {
/// Creates an initialiser for the module.
///
/// It is called when the module is loaded.
fn init(module: &'static ThisModule) -> impl init::PinInit<Self, error::Error>;
fn init(module: &'static ThisModule) -> impl pin_init::PinInit<Self, error::Error>;
}
impl<T: Module> InPlaceModule for T {
fn init(module: &'static ThisModule) -> impl init::PinInit<Self, error::Error> {
fn init(module: &'static ThisModule) -> impl pin_init::PinInit<Self, error::Error> {
let initer = move |slot: *mut Self| {
let m = <Self as Module>::init(module)?;
@@ -130,7 +126,7 @@ impl<T: Module> InPlaceModule for T {
};
// SAFETY: On success, `initer` always fully initialises an instance of `Self`.
unsafe { init::pin_init_from_closure(initer) }
unsafe { pin_init::pin_init_from_closure(initer) }
}
}