@@ -44,6 +44,7 @@ pub trait DriverOps {
4444 unsafe fn register (
4545 reg : * mut Self :: RegType ,
4646 name : & ' static CStr ,
47+ module : & ' static ThisModule ,
4748 id_table : * const Self :: RawIdType ,
4849 ) -> Result ;
4950
@@ -85,17 +86,21 @@ impl<T: DriverOps> Registration<T> {
8586 /// Allocates a pinned registration object and registers it.
8687 ///
8788 /// Returns a pinned heap-allocated representation of the registration.
88- pub fn new_pinned ( name : & ' static CStr ) -> Result < Pin < Box < Self > > > {
89+ pub fn new_pinned ( name : & ' static CStr , module : & ' static ThisModule ) -> Result < Pin < Box < Self > > > {
8990 let mut reg = Pin :: from ( Box :: try_new ( Self :: new ( ) ) ?) ;
90- reg. as_mut ( ) . register ( name) ?;
91+ reg. as_mut ( ) . register ( name, module ) ?;
9192 Ok ( reg)
9293 }
9394
9495 /// Registers a driver with its subsystem.
9596 ///
9697 /// It must be pinned because the memory block that represents the registration is potentially
9798 /// self-referential.
98- pub fn register ( self : Pin < & mut Self > , name : & ' static CStr ) -> Result {
99+ pub fn register (
100+ self : Pin < & mut Self > ,
101+ name : & ' static CStr ,
102+ module : & ' static ThisModule ,
103+ ) -> Result {
99104 // SAFETY: We never move out of `this`.
100105 let this = unsafe { self . get_unchecked_mut ( ) } ;
101106 if this. is_registered {
@@ -114,6 +119,7 @@ impl<T: DriverOps> Registration<T> {
114119 T :: register (
115120 this. concrete_reg . get ( ) ,
116121 name,
122+ module,
117123 & this. id_table [ 0 ] as * const _ as * const _ ,
118124 )
119125 } ?;
@@ -174,9 +180,9 @@ pub struct Module<T: DriverOps> {
174180}
175181
176182impl < T : DriverOps > KernelModule for Module < T > {
177- fn init ( name : & ' static CStr , _module : & ' static ThisModule ) -> Result < Self > {
183+ fn init ( name : & ' static CStr , module : & ' static ThisModule ) -> Result < Self > {
178184 Ok ( Self {
179- _driver : Registration :: new_pinned ( name) ?,
185+ _driver : Registration :: new_pinned ( name, module ) ?,
180186 } )
181187 }
182188}
0 commit comments