All of lore.kernel.org
 help / color / mirror / Atom feed
* post_coreinitcall and module_init() in tty_io.c linux kernel 2.6.10
@ 2007-10-18 10:04 Deepak Gaur
  2007-10-18 10:11 ` Deepak Gaur
  0 siblings, 1 reply; 3+ messages in thread
From: Deepak Gaur @ 2007-10-18 10:04 UTC (permalink / raw)
  To: linux-kernel

Hi all,

I am novice in field of linux device drivers. I have a small question regarding module
_init() call in file drivers/char/tty_io.c. In this file there are two init calls mentioned 

(a) postcore_initcall(tty_class_init);
(b) module_init(tty_init);

The postcore_initcall is defined in include/linux/init.h as
-----------------------------------------------------------------------
/**
 * module_init() - driver initialization entry point
 * @x: function to be run at kernel boot time or module insertion
 *
 * module_init() will either be called during do_initcalls (if
 * builtin) or at module insertion time (if a module).  There can only
 * be one per module.
 */
#define module_init(x)  __initcall(x);

/**
 * module_exit() - driver exit entry point
 * @x: function to be run when driver is removed
 *
 * module_exit() will wrap the driver clean-up code
 * with cleanup_module() when used with rmmod when
 * the driver is a module.  If the driver is statically
 * compiled into the kernel, module_exit() has no effect.
 * There can only be one per module.
 */
#define module_exit(x)  __exitcall(x);

#else /* MODULE */

/* Don't use these in modules, but some people do... */
#define core_initcall(fn)               module_init(fn)
#define postcore_initcall(fn)           module_init(fn)
#define arch_initcall(fn)               module_init(fn)
#define subsys_initcall(fn)             module_init(fn)
#define fs_initcall(fn)                 module_init(fn)
#define device_initcall(fn)             module_init(fn)
#define late_initcall(fn)               module_init(fn)

---------------------------------------------------------

It's written in quoted text that "There can only be one per module". But in tty_io.c
there are two; postcore_initcall also maps to module_init. Each call is using different
init functions and both functions seems to be required to be executed for proper
functioning of module.


So my query is 

(1) Which one of the two (postcore_initcall/module_init) get executed and when?
(2) If both get executed does it not break the rule that a kernel module should have
only one module_init() and one module_exit()?

with warm regards
 
Deepak Gaur


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-10-18 16:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-18 10:04 post_coreinitcall and module_init() in tty_io.c linux kernel 2.6.10 Deepak Gaur
2007-10-18 10:11 ` Deepak Gaur
2007-10-18 16:49   ` Randy Dunlap

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.