Re: specifying the order of calling kernel functions (or modules)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 30 Sep 2006 19:42:05 +0900 Seongsu Lee wrote:

> On Thu, Sep 28, 2006 at 11:47:02AM -0400, [email protected] 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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux