mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-18 23:09:29 +02:00
rust: macros: remove THIS_MODULE static from module!
All users have been migrated to `ModuleMetadata::THIS_MODULE` const or `this_module::<LocalModule>()` helper. The `static THIS_MODULE` generated by the `module!` macro is no longer referenced anywhere, so remove it to avoid having two sources of the same `ThisModule` pointer. Assisted-by: opencode:glm-5.2 Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org> Reviewed-by: Gary Guo <gary@garyguo.net> Acked-by: Danilo Krummrich <dakr@kernel.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Acked-by: Petr Pavlu <petr.pavlu@suse.com> Signed-off-by: Alvin Sun <alvin.sun@linux.dev> Link: https://patch.msgid.link/20260811-fix-fops-owner-v10-9-7e71776f9dbe@linux.dev Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
@@ -497,22 +497,6 @@ pub(crate) fn module(info: ModuleInfo) -> Result<TokenStream> {
|
||||
/// Used by the printing macros, e.g. [`info!`].
|
||||
const __LOG_PREFIX: &[u8] = #name_cstr.to_bytes_with_nul();
|
||||
|
||||
// SAFETY: `__this_module` is constructed by the kernel at load time and will not be
|
||||
// freed until the module is unloaded.
|
||||
#[cfg(MODULE)]
|
||||
static THIS_MODULE: ::kernel::ThisModule = unsafe {
|
||||
extern "C" {
|
||||
static __this_module: ::kernel::types::Opaque<::kernel::bindings::module>;
|
||||
};
|
||||
|
||||
::kernel::ThisModule::from_ptr(__this_module.get())
|
||||
};
|
||||
|
||||
#[cfg(not(MODULE))]
|
||||
static THIS_MODULE: ::kernel::ThisModule = unsafe {
|
||||
::kernel::ThisModule::from_ptr(::core::ptr::null_mut())
|
||||
};
|
||||
|
||||
/// The `LocalModule` type is the type of the module created by `module!`,
|
||||
/// `module_pci_driver!`, `module_platform_driver!`, etc.
|
||||
type LocalModule = #type_;
|
||||
|
||||
Reference in New Issue
Block a user