We have new THIS_MODULE and ThisModule is now trait. Pass THIS_MODULE as generic type parameter which is current convention.
Signed-off-by: Kari Argillander <[email protected]> --- drivers/block/rnull/configfs.rs | 2 +- rust/kernel/configfs.rs | 46 +++++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/drivers/block/rnull/configfs.rs b/drivers/block/rnull/configfs.rs index 2f5a7da03af5..7223ee7c3032 100644 --- a/drivers/block/rnull/configfs.rs +++ b/drivers/block/rnull/configfs.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 -use super::{NullBlkDevice, THIS_MODULE}; +use super::NullBlkDevice; use kernel::{ block::mq::gen_disk::{GenDisk, GenDiskBuilder}, c_str, diff --git a/rust/kernel/configfs.rs b/rust/kernel/configfs.rs index fe80439ab21f..908cb98d404f 100644 --- a/rust/kernel/configfs.rs +++ b/rust/kernel/configfs.rs @@ -110,16 +110,21 @@ //! [C documentation]: srctree/Documentation/filesystems/configfs.rst //! [`rust_configfs.rs`]: srctree/samples/rust/rust_configfs.rs -use crate::alloc::flags; -use crate::container_of; -use crate::page::PAGE_SIZE; -use crate::prelude::*; -use crate::str::CString; -use crate::sync::Arc; -use crate::sync::ArcBorrow; -use crate::types::Opaque; -use core::cell::UnsafeCell; -use core::marker::PhantomData; +use crate::{ + alloc::flags, + container_of, + page::PAGE_SIZE, + prelude::*, + str::CString, + sync::Arc, + sync::ArcBorrow, + this_module::ThisModule, + types::Opaque, // +}; +use core::{ + cell::UnsafeCell, + marker::PhantomData, // +}; /// A configfs subsystem. /// @@ -744,8 +749,7 @@ macro_rules! impl_item_type { ($tpe:ty) => { impl<Data> ItemType<$tpe, Data> { #[doc(hidden)] - pub const fn new_with_child_ctor<const N: usize, Child>( - owner: &'static ThisModule, + pub const fn new_with_child_ctor<const N: usize, Child, TM: ThisModule>( attributes: &'static AttributeList<N, Data>, ) -> Self where @@ -754,7 +758,7 @@ pub const fn new_with_child_ctor<const N: usize, Child>( { Self { item_type: Opaque::new(bindings::config_item_type { - ct_owner: owner.as_ptr(), + ct_owner: TM::OWNER.as_ptr(), ct_group_ops: GroupOperationsVTable::<Data, Child>::vtable_ptr().cast_mut(), ct_item_ops: ItemOperationsVTable::<$tpe, Data>::vtable_ptr().cast_mut(), ct_attrs: core::ptr::from_ref(attributes).cast_mut().cast(), @@ -765,13 +769,12 @@ pub const fn new_with_child_ctor<const N: usize, Child>( } #[doc(hidden)] - pub const fn new<const N: usize>( - owner: &'static ThisModule, + pub const fn new<const N: usize, TM: ThisModule>( attributes: &'static AttributeList<N, Data>, ) -> Self { Self { item_type: Opaque::new(bindings::config_item_type { - ct_owner: owner.as_ptr(), + ct_owner: TM::OWNER.as_ptr(), ct_group_ops: core::ptr::null_mut(), ct_item_ops: ItemOperationsVTable::<$tpe, Data>::vtable_ptr().cast_mut(), ct_attrs: core::ptr::from_ref(attributes).cast_mut().cast(), @@ -875,8 +878,7 @@ fn as_ptr(&self) -> *const bindings::config_item_type { /// = kernel::configfs::ItemType::< /// configfs::Subsystem<Configuration>, /// Configuration -/// >::new_with_child_ctor::<N,Child>( -/// THIS_MODULE.as_ref(), +/// >::new_with_child_ctor::<N, Child, crate::THIS_MODULE>( /// &CONFIGURATION_ATTRS /// ); /// @@ -1019,8 +1021,8 @@ macro_rules! configfs_attrs { const [<$no_child:upper>]: bool = true; static [< $data:upper _TPE >] : $crate::configfs::ItemType<$container, $data> = - $crate::configfs::ItemType::<$container, $data>::new::<N>( - THIS_MODULE.as_ref(), &[<$ data:upper _ATTRS >] + $crate::configfs::ItemType::<$container, $data>::new::<N, crate::THIS_MODULE>( + &[<$ data:upper _ATTRS >] ); )? @@ -1028,8 +1030,8 @@ macro_rules! configfs_attrs { static [< $data:upper _TPE >]: $crate::configfs::ItemType<$container, $data> = $crate::configfs::ItemType::<$container, $data>:: - new_with_child_ctor::<N, $child>( - THIS_MODULE.as_ref(), &[<$ data:upper _ATTRS >] + new_with_child_ctor::<N, $child, crate::THIS_MODULE>( + &[<$ data:upper _ATTRS >] ); )? -- 2.43.0

