EmbLogic's Blog

Module code to show how parameters can be passed to a module while loading it with the help of macro called module_param().

RCS file: header.h,v
Working file: header.h
head: 1.8
branch:
locks: strict
root: 1.8
access list:
symbolic names:
keyword substitution: kv
total revisions: 8;    selected revisions: 8
description:
Base header file that includes the definitions of all the macros,structures and contains the necessary header files required by the module code.
—————————-
revision 1.8    locked by: root;
date: 2014/02/27 20:02:53;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/moduleparam.h> is added to support the module_param() macro.With the help of this macro parameters can be passed to a module while loading it.
—————————-
revision 1.7
date: 2014/02/27 19:28:38;  author: root;  state: Exp;  lines: +4 -0
A macro called DEVICE_NAME is defined using #define.
—————————-
revision 1.6
date: 2014/02/27 19:20:01;  author: root;  state: Exp;  lines: +1 -0
Header file:<linux/fs.h> is added to the base header file to support various functions like alloc_chrdev_region(),unregister_chrdev_region(),etc.
—————————-
revision 1.5
date: 2014/02/27 18:44:36;  author: root;  state: Exp;  lines: +4 -0
A macro called DEBUG is defined using #define.
—————————-
revision 1.4
date: 2014/02/27 18:41:13;  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 18:38:11;  author: root;  state: Exp;  lines: +1 -1
Header file:<linux/module.h> is added to the base header file to provide support for a great many number of macros like:MODULE_LICENSE , MODULE_AUTHOR,etc.
—————————-
revision 1.2
date: 2014/02/27 18:36:07;  author: root;  state: Exp;  lines: +2 -0
Header file:<linux/init.h> is added to the base header file to provide support for module_init() and module_exit() macros.
—————————-
revision 1.1
date: 2014/02/27 18:35:18;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: initial.c,v
Working file: initial.c
head: 1.5
branch:
locks: strict
root: 1.5
access list:
symbolic names:
keyword substitution: kv
total revisions: 5;    selected revisions: 5
description:
File containing the module’s initialization function that is called at module insertion time.
—————————-
revision 1.5    locked by: root;
date: 2014/02/27 20:12:29;  author: root;  state: Exp;  lines: +7 -1
module_param() macro is used.With the help of this macro parameters can be passed to the module while loading it,when using “insmod”.
module_param() macro takes three arguments:
1.The name of the variable,
2.The type of the variable,
3.Permissions.
—————————-
revision 1.4
date: 2014/02/27 19:58:09;  author: root;  state: Exp;  lines: +1 -1
alloc_chrdev_region() function is used to allocate dynamically a major number.On success,the first parameter of this function stores the first device number.
—————————-
revision 1.3
date: 2014/02/27 19:31:39;  author: root;  state: Exp;  lines: +11 -0
Header file: “decleration.h” is added to include all the variable declerations.
—————————-
revision 1.2
date: 2014/02/27 18:50:37;  author: root;  state: Exp;  lines: +7 -0
module_init() macro is used to define which function is called during module’s insertion time.
__init token hints to the kernel that the function is used only at the initialization time.
The function specified by the module_init() macro is declared static because it is not meant to be visible outside the file.
—————————-
revision 1.1
date: 2014/02/27 18:49:06;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: cleanup.c,v
Working file: cleanup.c
head: 1.5
branch:
locks: strict
root: 1.5
access list:
symbolic names:
keyword substitution: kv
total revisions: 5;    selected revisions: 5
description:
File that contains the cleanup function which returns all the resources back to the system.
—————————-
revision 1.5    locked by: root;
date: 2014/02/27 20:15:39;  author: root;  state: Exp;  lines: +3 -1
A variable of type int representing the number of devices is included here using extern.
—————————-
revision 1.4
date: 2014/02/27 19:36:03;  author: root;  state: Exp;  lines: +1 -0
A variable dev of type dev_t storing the device number is included here using extern.
—————————-
revision 1.3
date: 2014/02/27 19:33:49;  author: root;  state: Exp;  lines: +3 -1
Called unregister_chrdev_region() which is having 2 arguments: device number and the total number of device numbers to unregister.
—————————-
revision 1.2
date: 2014/02/27 18:58:02;  author: root;  state: Exp;  lines: +14 -0
module_exit() macro is used to define which function is to be called at module removal time.\
The function specified by the module_exit() macro is declared static because it is not meant to be visible outside the file.
—————————-
revision 1.1
date: 2014/02/27 18:55:42;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: decleration.h,v
Working file: decleration.h
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
All the variable declerations are done inside this header file.
—————————-
revision 1.2    locked by: root;
date: 2014/02/27 20:06:26;  author: root;  state: Exp;  lines: +1 -0
A variable of type int is declared representing the number of devices.
—————————-
revision 1.1
date: 2014/02/27 19:30:54;  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>