File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -282,7 +282,10 @@ pub fn module(ts: TokenStream) -> TokenStream {
282
282
#[used]
283
283
static __{name}_{param_name}_struct: __{name}_{param_name}_RacyKernelParam = __{name}_{param_name}_RacyKernelParam(kernel::bindings::kernel_param {{
284
284
name: __{name}_{param_name}_name,
285
- // TODO: `THIS_MODULE`
285
+ // SAFETY: `__this_module` is constructed by the kernel at load time and will not be freed until the module is unloaded.
286
+ #[cfg(MODULE)]
287
+ mod_: unsafe {{ &kernel::bindings::__this_module as *const _ as *mut _ }},
288
+ #[cfg(not(MODULE))]
286
289
mod_: core::ptr::null_mut(),
287
290
ops: unsafe {{ &kernel::bindings::param_ops_{param_kernel_type} }} as *const kernel::bindings::kernel_param_ops,
288
291
perm: {permissions},
@@ -309,6 +312,7 @@ pub fn module(ts: TokenStream) -> TokenStream {
309
312
"
310
313
static mut __MOD: Option<{type_}> = None;
311
314
315
+ // SAFETY: `__this_module` is constructed by the kernel at load time and will not be freed until the module is unloaded.
312
316
#[cfg(MODULE)]
313
317
static THIS_MODULE: kernel::ThisModule = unsafe {{ kernel::ThisModule::from_ptr(&kernel::bindings::__this_module as *const _ as *mut _) }};
314
318
#[cfg(not(MODULE))]
You can’t perform that action at this time.
0 commit comments