Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
584 views
in Technique[技术] by (71.8m points)

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...