EmbLogic's Blog

Simplest driver module code to understand the macros module_init() and module_exit().

RCS file: header.h,v
Working file: header.h
head: 1.5
branch:
locks: strict
root: 1.5
access list:
symbolic names:
keyword substitution: kv
total revisions: 5;    selected revisions: 5
description:
Base header file that includes the definitions of all the macros,structure definitions and necessary header files.
—————————-
revision 1.5    locked by: root;
date: 2014/02/27 02:44:48;  author: root;  state: Exp;  lines: +4 -0
A special macro called DEBUG is created using #define.
—————————-
revision 1.4
date: 2014/02/27 02:28:52;  author: root;  state: Exp;  lines: +2 -0
A special macro called MODULE_LICENSE is used to tell the kernel that the module bears a free license without such a decleration the kernel complains.
—————————-
revision 1.3
date: 2014/02/27 02:26:08;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/module.h> is added to support a great many number of macros like:MODULE_LICENSE , MODULE_AUTHOR .
..
—————————-
revision 1.2
date: 2014/02/27 02:20:56;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/init.h> is added to support module_init() and module_exit() macros that specifies the module’s initialization and cleanup functions.
—————————-
revision 1.1
date: 2014/02/27 02:18:53;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: initial.c,v
Working file: initial.c
head: 1.4
branch:
locks: strict
root: 1.4
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;    selected revisions: 4
description:
File that contains the module’s initialization function that is called at the module insertion time.
—————————-
revision 1.4    locked by: root;
date: 2014/02/27 02:57:43;  author: root;  state: Exp;  lines: +3 -1
Error during compilation.
Bug fixed.Issue:return statement is not included.
—————————-
revision 1.3
date: 2014/02/27 02:47:22;  author: root;  state: Exp;  lines: +7 -0
printk() is used to mark the beginning and end of the initialization function.printk() sends the messages to the kernel log.
—————————-
revision 1.2
date: 2014/02/27 02:36:50;  author: root;  state: Exp;  lines: +7 -0
module_init() macro is used to define which function is called during module’s insertion time.
initialization function is declared static because it is not meant to be visible outside the file.
__init token in the definition hints to the kernel that the given function is used only at the initialization time.
—————————-
revision 1.1
date: 2014/02/27 02:18:58;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: cleanup.c,v
Working file: cleanup.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
File that contains the module’s cleanup function which unregisters interfaces and returns all resources to the system before the module is removed.
—————————-
revision 1.2    locked by: root;
date: 2014/02/27 02:51:54;  author: root;  state: Exp;  lines: +13 -0
module_exit() macro is used to define which function to call during module unloading.
__exit() token hints to the kernel that the given function is used only during module unloading.
—————————-
revision 1.1
date: 2014/02/27 02:19:00;  author: root;  state: Exp;
Initial revision
=============================================================================

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>