LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (http://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   How to adjust the order of loading device driver(built-in type) (http://www.linuxquestions.org/questions/linux-kernel-70/how-to-adjust-the-order-of-loading-device-driver-built-in-type-867354/)

morris chen 03-09-2011 12:11 AM

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.

Thanks a lot.

Regards,
Morris

andrewthomas 03-09-2011 12:38 AM

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.

morris chen 03-09-2011 01:12 AM

Quote:

Originally Posted by andrewthomas (Post 4283615)
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?

Regards,
Morris

andrewthomas 03-09-2011 01:24 AM

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.

morris chen 03-09-2011 01:38 AM

Quote:

Originally Posted by andrewthomas (Post 4283665)
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.

Got it. Thanks

Morris

andrewthomas 03-09-2011 01:40 AM

You're welcome.

If you are satisfied with the solution, then mark the thread as [SOLVED] using the thread tools menu.

morris chen 03-09-2011 01:47 AM

Quote:

Originally Posted by andrewthomas (Post 4283689)
You're welcome.

If you are satisfied with the solution, then mark the thread as [SOLVED] using the thread tools menu.


I think it's a good alternative.
But I still want to know how to adjust or control the order of loading linux device driver without using ko module.

Thanks

Regards,
Morris

dpstrand 04-27-2011 04:47 PM

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?

dpstrand 04-27-2011 07:57 PM

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.


All times are GMT -5. The time now is 05:06 PM.