[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241113171638.5d1343e5@canb.auug.org.au>
Date: Wed, 13 Nov 2024 17:16:38 +1100
From: Stephen Rothwell <sfr@...b.auug.org.au>
To: Miguel Ojeda <ojeda@...nel.org>, Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>
Cc: Alice Ryhl <aliceryhl@...gle.com>, Aliet Exposito Garcia
<aliet.exposito@...il.com>, Linux Kernel Mailing List
<linux-kernel@...r.kernel.org>, Linux Next Mailing List
<linux-next@...r.kernel.org>
Subject: linux-next: manual merge of the rust tree with the ftrace tree
Hi all,
Today's linux-next merge of the rust tree got a conflict in:
rust/kernel/lib.rs
between commit:
ad37bcd965fd ("rust: add tracepoint support")
from the ftrace tree and commit:
ce1c54fdff7c ("rust: kernel: move `FromBytes` and `AsBytes` traits to a new `transmute` module")
from the rust tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
--
Cheers,
Stephen Rothwell
diff --cc rust/kernel/lib.rs
index 5dc3f2c11031,bf8d7f841f94..000000000000
--- a/rust/kernel/lib.rs
+++ b/rust/kernel/lib.rs
@@@ -60,7 -56,7 +63,8 @@@ pub mod str
pub mod sync;
pub mod task;
pub mod time;
+pub mod tracepoint;
+ pub mod transmute;
pub mod types;
pub mod uaccess;
pub mod workqueue;
@@@ -89,32 -85,9 +93,32 @@@ pub trait Module: Sized + Sync + Send
fn init(module: &'static ThisModule) -> error::Result<Self>;
}
+/// A module that is pinned and initialised in-place.
+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>;
+}
+
+impl<T: Module> InPlaceModule for T {
+ fn init(module: &'static ThisModule) -> impl init::PinInit<Self, error::Error> {
+ let initer = move |slot: *mut Self| {
+ let m = <Self as Module>::init(module)?;
+
+ // SAFETY: `slot` is valid for write per the contract with `pin_init_from_closure`.
+ unsafe { slot.write(m) };
+ Ok(())
+ };
+
+ // SAFETY: On success, `initer` always fully initialises an instance of `Self`.
+ unsafe { init::pin_init_from_closure(initer) }
+ }
+}
+
/// Equivalent to `THIS_MODULE` in the C API.
///
- /// C header: [`include/linux/export.h`](srctree/include/linux/export.h)
+ /// C header: [`include/linux/init.h`](srctree/include/linux/init.h)
pub struct ThisModule(*mut bindings::module);
// SAFETY: `THIS_MODULE` may be used from all threads within a module.
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists