How to adjust the order of loading device driver(built-in type)
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to adjust the order of loading device driver(built-in type)
Dear Guys,
Would you know how the kernel decides the order of loading device driver(built-in type)?
For the ko type, I could control the order by editing rc.c file.
However, for the built-in type, I don't know how to control it.
If you need one to load before another, compile the one you want to load first into the kernel and the one you want to load second as a module.
So, you mean that it depends on who is compiled firstly.
For first to compile and insert into kernel, it will fistly load in the order of loading device driver.
Is it right?
No, what I mean is: say you want your pata drive to be sda and your sata drive to be sdb, then when you compile your kernel you would want to have the driver for the pata drive to be compiled into the kernel <y> and the driver for your sata drive to be a module <*>.
The kernel will load the drivers that are compiled into the kernel first and then the modules next.
This is the only way that I know of how to influence the order of loading drivers. If two drivers are both compiled into the kernel, I have no idea of what decides which one to load first.
No, what I mean is: say you want your pata drive to be sda and your sata drive to be sdb, then when you compile your kernel you would want to have the driver for the pata drive to be compiled into the kernel <y> and the driver for your sata drive to be a module <*>.
The kernel will load the drivers that are compiled into the kernel first and then the modules next.
This is the only way that I know of how to influence the order of loading drivers. If two drivers are both compiled into the kernel, I have no idea of what decides which one to load first.
I am dealing with this problem today with a custom flash driver that hooks to mtd, and I need to make sure the mtd core driver is loaded first (otherwise add_mtd_device causes a kernel panic). If my driver is a module it works fine, but now I want to make it built-in. Did you ever figure this out?
For now I switch my module_init call to late_initcall, and that worked for me. My builtin driver gets loaded last now. If there is a better way to handle this, please post it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.