MODULE

tech2026-06-08  2

驱动程序里经常看到MODULE_DEVICE_TABLE这个宏定义在{kernel}/include/linux/module.h:

Dynamic loading of modules into the kernel (一般用于动态加载驱动也就是热插拔的时候使用)

#ifndef _LINUX_MODULE_H #define _LINUX_MODULE_H /* * Dynamic loading of modules into the kernel. * * Rewritten by Richard Henderson <rth@tamu.edu> Dec 1996 * Rewritten again by Rusty Russell, 2002 */ ...... #ifdef MODULE /* Creates an alias so file2alias.c can find device table. */ #define MODULE_DEVICE_TABLE(type, name) \ extern const typeof(name) __mod_##type##__##name##_device_table \ __attribute__ ((unused, alias(__stringify(name)))) #else /* !MODULE */ #define MODULE_DEVICE_TABLE(type, name) #endif

type是类型,name是驱动的名称

最新回复(0)