初始化驱动程序时,module_init和subsys_initcall有什么区别? [英] What is the difference between module_init and subsys_initcall while initializing the driver?

查看:455
本文介绍了初始化驱动程序时,module_init和subsys_initcall有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

初始化驱动程序时module_initsubsys_initcall有什么区别?

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

推荐答案

差异与执行时间(或更确切地说,执行顺序)有关.即,保证在声明为module_init的过程之前执行声明为subsys_initcall的过程.此顺序可确保在设备驱动程序尝试利用前者的功能(例如,设备驱动程序注册为子系统设备)之前初始化子系统和平台驱动程序.

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).

每一个的实际宏定义取决于是否为(可装载)模块配置了内核.这些宏(和其他init宏)的定义可以在

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

请注意,subsys_initcall()仅可用于内置(静态链接)模块.
module_init可以由内置模块或可加载模块使用.

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.

这篇关于初始化驱动程序时,module_init和subsys_initcall有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆