Messages in this thread | | | Date | Sat, 30 Sep 2006 09:47:31 -0700 | From | Randy Dunlap <> | Subject | Re: specifying the order of calling kernel functions (or modules) |
| |
On Sat, 30 Sep 2006 19:42:05 +0900 Seongsu Lee wrote:
> On Thu, Sep 28, 2006 at 11:47:02AM -0400, Valdis.Kletnieks@vt.edu wrote: > > On Thu, 28 Sep 2006 19:17:24 +0900, Seongsu Lee said: > > > I am a beginner of kernel module programming. I want to > > > specify the order of calling functions that I registered > > > by EXPORT_SYMBOL(). (or modules) > > > > What problem did you expect to solve by specifying the order? Phrased > > differently, why does the order matter? > > I am playing with mtdconcat in MTD (Memory Technology Device). > > For example: > mtdconcat must be called after initializing the lower device and > partitions. So, the order of calling functions must be decided > always. > > Actuall, the functions in Linux kernel are called in a order. I want > to know how to specify these orders. > > Sorry for short English. Thank you for your help.
a. linker order matters (order in Makefiles)
b. initcall order matters. See include/linux/init.h, especially this part:
/* initcalls are now grouped by functionality into separate * subsections. Ordering inside the subsections is determined * by link order. * For backwards compatibility, initcall() puts the call in * the device init subsection. */
#define __define_initcall(level,fn) \ static initcall_t __initcall_##fn __attribute_used__ \ __attribute__((__section__(".initcall" level ".init"))) = fn
#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)
c. "function call" order matters :)
--- ~Randy - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |