* Drivers statically linked in the wrong order
@ 2006-06-26 11:59 David Johnson
2006-06-26 12:30 ` Arjan van de Ven
0 siblings, 1 reply; 3+ messages in thread
From: David Johnson @ 2006-06-26 11:59 UTC (permalink / raw)
To: Linux Kernel Mailing List
Hi,
I'm currently working on a few kernel drivers (not yet merged into the
kernel). The main driver (for talking to some hardware over an I2C bus)
relies on another (for the I2C bus itself).
When compiled as modules, loading the main driver with modprobe loads the I2C
bus driver automatically. But when statically linked into the kernel the main
driver is loaded before the I2C bus driver, which causes it to barf.
How can I get the I2C bus driver to be linked before the main driver? I've
tried re-ordering things in Makefiles, but nothing I've tried seems to make
any difference.
The I2C bus driver is:
drivers/i2c/busses/i2c-envctrl.c
While the main driver is:
arch/sparc64/kernel/env_envctrl.c
Any help would be greatly appreciated!
Thanks,
David.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Drivers statically linked in the wrong order
2006-06-26 11:59 Drivers statically linked in the wrong order David Johnson
@ 2006-06-26 12:30 ` Arjan van de Ven
2006-06-26 16:23 ` David Johnson
0 siblings, 1 reply; 3+ messages in thread
From: Arjan van de Ven @ 2006-06-26 12:30 UTC (permalink / raw)
To: Linux Kernel Mailing List
> How can I get the I2C bus driver to be linked before the main driver? I've
> tried re-ordering things in Makefiles, but nothing I've tried seems to make
> any difference.
Hi,
there are 2 levels of ordering;
1) the initcall level
2) the Makefile order
at equal initcall level, the Makefile order really is the order that
matters, however... if there is not the same initcall level, then that
level overrules.
So to your problem, you have 2 choices
1) try to fix the makefile issue some more (will fail if there are
different initcall levels)
2) Use initcall levels yourself...
see
#define core_initcall(fn) __define_initcall("1",fn)
#define postcore_initcall(fn) __define_initcall("2",fn)
#define arch_initcall(fn) __define_initcall("3",fn)
#define subsys_initcall(fn) __define_initcall("4",fn)
#define fs_initcall(fn) __define_initcall("5",fn)
#define device_initcall(fn) __define_initcall("6",fn)
#define late_initcall(fn) __define_initcall("7",fn)
in include/linux.init.h
iirc a normal module_init() is over type "device_initcall", so you can
make your must-be-last one a late_initcall(), or your "must be first" a
subsys_initcall....
(note: you can use late_initcall() and friends instead of module_init;
for the module case these get defined to be module_init() anyway, so no
need for ugly ifdefs in your drivers)
Does this help?
Greetings,
Arjan van de Ven
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Drivers statically linked in the wrong order
2006-06-26 12:30 ` Arjan van de Ven
@ 2006-06-26 16:23 ` David Johnson
0 siblings, 0 replies; 3+ messages in thread
From: David Johnson @ 2006-06-26 16:23 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: Linux Kernel Mailing List
On Monday 26 June 2006 13:30, you wrote:
>
> Does this help?
>
That's great - thanks!
Replacing module_init with subsys_initcall in the I2C bus driver has solved
the problem :-)
Regards,
David.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-06-26 16:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-26 11:59 Drivers statically linked in the wrong order David Johnson
2006-06-26 12:30 ` Arjan van de Ven
2006-06-26 16:23 ` David Johnson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®