The difference relates to timing, or more precisely, order of execution. That is, the procedure declared as subsys_initcall
is guaranteed to be executed before the procedure declared as module_init
. This ordering ensures that subsystem and platform drivers are initialized before device drivers try to utilize the former's functionality (e.g. a device driver registers as a subsystem device).
The actual macro definition for each depends on if the kernel is configured for (loadable) modules or not. The definition for these macros (and other init macros) can be found in include/linux/init.h
Note that subsys_initcall()
can only be used by a built-in (statically linked) module.
module_init
can be used by either built-in or loadable modules.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…