lkml.org 
[lkml]   [2006]   [Sep]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 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/

\
 
 \ /
  Last update: 2006-09-30 18:49    [W:0.077 / U:1.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site