diff options
Diffstat (limited to 'rust/macros/module.rs')
| -rw-r--r-- | rust/macros/module.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/rust/macros/module.rs b/rust/macros/module.rs index d62e9c1e2a89..80cb9b16f5aa 100644 --- a/rust/macros/module.rs +++ b/rust/macros/module.rs @@ -133,10 +133,10 @@ impl<'a> ModInfoBuilder<'a> { ::kernel::module_param::KernelParam::new( ::kernel::bindings::kernel_param {{ name: if ::core::cfg!(MODULE) {{ - ::kernel::c_str!(\"{param_name}\").as_bytes_with_nul() + ::kernel::c_str!(\"{param_name}\").to_bytes_with_nul() }} else {{ ::kernel::c_str!(\"{module_name}.{param_name}\") - .as_bytes_with_nul() + .to_bytes_with_nul() }}.as_ptr(), // SAFETY: `__this_module` is constructed by the kernel at load // time and will not be freed until the module is unloaded. @@ -205,6 +205,7 @@ struct ModuleInfo { description: Option<String>, alias: Option<Vec<String>>, firmware: Option<Vec<String>>, + imports_ns: Option<Vec<String>>, params: Option<Vec<Parameter>>, } @@ -263,6 +264,7 @@ impl ModuleInfo { "license", "alias", "firmware", + "imports_ns", "params", ]; const REQUIRED_KEYS: &[&str] = &["type", "name", "license"]; @@ -289,6 +291,7 @@ impl ModuleInfo { "license" => info.license = expect_string_ascii(it), "alias" => info.alias = Some(expect_string_array(it)), "firmware" => info.firmware = Some(expect_string_array(it)), + "imports_ns" => info.imports_ns = Some(expect_string_array(it)), "params" => info.params = Some(expect_params(it)), _ => panic!("Unknown key \"{key}\". Valid keys are: {EXPECTED_KEYS:?}."), } @@ -348,6 +351,11 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream { modinfo.emit("firmware", fw); } } + if let Some(imports) = &info.imports_ns { + for ns in imports { + modinfo.emit("import_ns", ns); + } + } // Built-in modules also export the `file` modinfo string. let file = @@ -383,7 +391,7 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream { type LocalModule = {type_}; impl ::kernel::ModuleMetadata for {type_} {{ - const NAME: &'static ::kernel::str::CStr = ::kernel::c_str!(\"{name}\"); + const NAME: &'static ::kernel::str::CStr = c\"{name}\"; }} // Double nested modules, since then nobody can access the public items inside. |
