init function invocation of drivers compiled into kernel

前端 未结 2 1581
Happy的楠姐
Happy的楠姐 2020-12-01 17:32

In Linux if device drivers are built as loadable kernel modules, then upon inserting the device driver kernel module, the kernel calls the init function of the device driver

2条回答
  •  不思量自难忘°
    2020-12-01 18:00

    As specified by the comments in kernel init.h

    "module_init() will either be called during do_initcalls() (if builtin) or at module insertion time (if a module)."

    If you look into init.h then you will see

    define module_init(x) __initcall(x);

    And if you closely observe then

    define __initcall(fn) device_initcall(fn)

    And

    define device_initcall(fn) __define_initcall("6",fn,6)

    So basically the module init leads to initcall (NOTE: only for statically compiled modules) at the time of boot only.

提交回复
热议问题