@@ -44,6 +44,7 @@ pub trait DriverOps {
44
44
unsafe fn register (
45
45
reg : * mut Self :: RegType ,
46
46
name : & ' static CStr ,
47
+ module : & ' static ThisModule ,
47
48
id_table : * const Self :: RawIdType ,
48
49
) -> Result ;
49
50
@@ -85,17 +86,21 @@ impl<T: DriverOps> Registration<T> {
85
86
/// Allocates a pinned registration object and registers it.
86
87
///
87
88
/// 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 > > > {
89
90
let mut reg = Pin :: from ( Box :: try_new ( Self :: new ( ) ) ?) ;
90
- reg. as_mut ( ) . register ( name) ?;
91
+ reg. as_mut ( ) . register ( name, module ) ?;
91
92
Ok ( reg)
92
93
}
93
94
94
95
/// Registers a driver with its subsystem.
95
96
///
96
97
/// It must be pinned because the memory block that represents the registration is potentially
97
98
/// 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 {
99
104
// SAFETY: We never move out of `this`.
100
105
let this = unsafe { self . get_unchecked_mut ( ) } ;
101
106
if this. is_registered {
@@ -114,6 +119,7 @@ impl<T: DriverOps> Registration<T> {
114
119
T :: register (
115
120
this. concrete_reg . get ( ) ,
116
121
name,
122
+ module,
117
123
& this. id_table [ 0 ] as * const _ as * const _ ,
118
124
)
119
125
} ?;
@@ -174,9 +180,9 @@ pub struct Module<T: DriverOps> {
174
180
}
175
181
176
182
impl < 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 > {
178
184
Ok ( Self {
179
- _driver : Registration :: new_pinned ( name) ?,
185
+ _driver : Registration :: new_pinned ( name, module ) ?,
180
186
} )
181
187
}
182
188
}
0 commit comments