What is the difference between module_init and subsys_initcall while initializing the driver?

后端 未结 1 1882
予麋鹿
予麋鹿 2020-12-02 23:45

What is the difference between module_init and subsys_initcall while initializing the driver?

相关标签:
1条回答
  • 2020-12-03 00:22

    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.

    0 讨论(0)
提交回复
热议问题