From: Kari Argillander <kari.argillander@gmail.com>
To: "Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-modules@vger.kernel.org,
Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Daniel Gomez <da.gomez@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>,
Aaron Tomlin <atomlin@atomlin.com>,
Kari Argillander <kari.argillander@gmail.com>
Subject: [PATCH RFC v2 11/11] rust: remove old version of ThisModule
Date: Tue, 06 Jan 2026 18:11:49 +0200 [thread overview]
Message-ID: <20260106-this_module_fix-v2-11-842ac026f00b@gmail.com> (raw)
In-Reply-To: <20260106-this_module_fix-v2-0-842ac026f00b@gmail.com>
There are now users anymore which use old ThisModule. Also new
ThisModule did have couple quirks which where there only to probide
fucntionality what old ThisModule provided. Those also are not needed
anymore.
Closes: https://github.com/Rust-for-Linux/linux/issues/212
Closes: https://github.com/Rust-for-Linux/linux/issues/1176
Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
---
rust/kernel/lib.rs | 47 -----------------------------------------------
rust/kernel/prelude.rs | 2 +-
2 files changed, 1 insertion(+), 48 deletions(-)
diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
index dec1d05ebe7b..e709f85ec4b5 100644
--- a/rust/kernel/lib.rs
+++ b/rust/kernel/lib.rs
@@ -201,32 +201,6 @@ fn init() -> impl pin_init::PinInit<Self, error::Error> {
}
}
-/// Equivalent to `THIS_MODULE` in the C API.
-///
-/// 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.
-unsafe impl Sync for ThisModule {}
-
-impl ThisModule {
- /// Creates a [`ThisModule`] given the `THIS_MODULE` pointer.
- ///
- /// # Safety
- ///
- /// The pointer must be equal to the right `THIS_MODULE`.
- pub const unsafe fn from_ptr(ptr: *mut bindings::module) -> ThisModule {
- ThisModule(ptr)
- }
-
- /// Access the raw pointer for this module.
- ///
- /// It is up to the user to use it correctly.
- pub const fn as_ptr(&self) -> *mut bindings::module {
- self.0
- }
-}
-
pub mod this_module {
//! Access to the module identity and ownership information.
//!
@@ -360,27 +334,6 @@ impl THIS_MODULE {
pub const fn name() -> &'static ::kernel::str::CStr {
$crate::c_str!($name)
}
-
- // TODO: Temporary to provide functionality old `THIS_MODULE` provided.
- // SAFETY: `__this_module` is constructed by the kernel at load time and
- // will not be freed until the module is unloaded.
- const ThisModule: ::kernel::ThisModule = unsafe {{
- ::kernel::ThisModule::from_ptr(
- <Self as ::kernel::this_module::ThisModule>::OWNER.as_ptr()
- )
- }};
-
- /// Gets a pointer to the underlying `struct module`.
- // TODO: Temporary to provide functionality old `THIS_MODULE` provided.
- pub const fn as_ptr(&self) -> *mut ::kernel::bindings::module {{
- Self::ThisModule.as_ptr()
- }}
-
- /// Gets a reference to the underlying `ThisModule`.
- /// TODO: Temporary to provide functionality old `THIS_MODULE` provided.
- pub const fn as_ref(&self) -> &'static ::kernel::ThisModule {{
- &Self::ThisModule
- }}
}
};
}
diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs
index 2877e3f7b6d3..66974ec20ef4 100644
--- a/rust/kernel/prelude.rs
+++ b/rust/kernel/prelude.rs
@@ -43,7 +43,7 @@
pub use super::error::{code::*, Error, Result};
-pub use super::{str::CStrExt as _, ThisModule};
+pub use super::str::CStrExt as _;
pub use super::init::InPlaceInit;
--
2.43.0
prev parent reply other threads:[~2026-01-06 16:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-06 16:11 [PATCH RFC v2 00/11] rust: Reimplement ThisModule to fix ownership problems Kari Argillander
2026-01-06 16:11 ` [PATCH RFC v2 01/11] rust: enable const_refs_to_static feature Kari Argillander
2026-01-06 16:11 ` [PATCH RFC v2 02/11] rust: add new ThisModule trait and THIS_MODULE impl Kari Argillander
2026-01-06 16:11 ` [PATCH RFC v2 03/11] rust: miscdevice: fix use after free because missing .owner Kari Argillander
2026-01-06 16:11 ` [PATCH RFC v2 04/11] rust: block: fix missing owner field in block_device_operations Kari Argillander
2026-01-06 16:11 ` [PATCH RFC v2 05/11] rust: drm: fix missing owner in file_operations Kari Argillander
2026-01-06 16:11 ` [PATCH RFC v2 06/11] rust: driver: make RegistrationOps::register() to use new ThisModule Kari Argillander
2026-01-06 16:11 ` [PATCH RFC v2 07/11] rust: phy: make Registration::register() " Kari Argillander
2026-01-06 16:11 ` [PATCH RFC v2 08/11] rust: binder: use new THIS_MODULE Kari Argillander
2026-01-06 16:11 ` [PATCH RFC v2 09/11] rust: remove module argument from InPlaceModule::init() Kari Argillander
2026-01-06 16:11 ` [PATCH RFC v2 10/11] rust: remove kernel::ModuleMetadata Kari Argillander
2026-01-06 16:11 ` Kari Argillander [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260106-this_module_fix-v2-11-842ac026f00b@gmail.com \
--to=kari.argillander@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=atomlin@atomlin.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=da.gomez@kernel.org \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=mcgrof@kernel.org \
--cc=ojeda@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=samitolvanen@google.com \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox