On 10/22/24 23:31, Danilo Krummrich wrote: + +/// Create device table alias for modpost. +#[macro_export] +macro_rules! module_device_table { + ($table_type: literal, $module_table_name:ident, $table_name:ident) => { + #[rustfmt::skip] + #[export_name = + concat!("__mod_", $table_type, "__", stringify!($table_name), "_device_table") + ] + static $module_table_name: [core::mem::MaybeUninit<u8>; $table_name.raw_ids().size()] = + unsafe { core::mem::transmute_copy($table_name.raw_ids()) }; + }; +} This needs a cfg(MODULE) or similar, otherwise it is impossible to build multiple modules into the kernel. (See https://github.com/AsahiLinux/linux/commit/b63a09090638ff92993c450132387a77e1e68c9a)