EmbLogic's Blog

Registering a character device driver with Major and Minor number in kernel

RCS file: header.h,v
Working file: header.h
head: 1.3
branch:
locks: strict
raghav: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
This is a seperate header file where i have included all the necessary header file required for writing character
including linux/init.h and linux/module.h
—————————-
revision 1.3    locked by: raghav;
date: 2014/02/13 05:47:34;  author: raghav;  state: Exp;  lines: +0 -1
header file <init.h> is included to support module_init and module_exit
—————————-
revision 1.2
date: 2014/02/13 05:24:24;  author: raghav;  state: Exp;  lines: +0 -1
Included the module licence GPL to make it authorized
—————————-
revision 1.1
date: 2014/02/13 05:23:05;  author: raghav;  state: Exp;
Initial revision
=============================================================================
RCS file: entry.c,v
Working file: entry.c
head: 1.7
branch:
locks: strict
raghav: 1.7
access list:
symbolic names:
keyword substitution: kv
total revisions: 7;    selected revisions: 7
description:
program to insert a driver file inside our kernel
—————————-
revision 1.7    locked by: raghav;
date: 2014/02/13 05:43:43;  author: raghav;  state: Exp;  lines: +10 -15
included the alloc_chrdev_region to register the driver number and get the major and minor number using its first argument dev
Major no is allocated by kernel and minor no is allocated by driver to devices
—————————-
revision 1.6
date: 2014/02/11 12:33:38;  author: raghav;  state: Exp;  lines: +2 -2
ERROR: i was using name function name “out” for exit function
Now i changed it to outo , and now it works without showing any bug
—————————-
revision 1.5
date: 2014/02/11 12:31:14;  author: raghav;  state: Exp;  lines: +2 -1
ERROR: forget to write retern 0 in init function
—————————-
revision 1.4
date: 2014/02/11 12:27:34;  author: raghav;  state: Exp;  lines: +5 -5
creating  a seperate Makefile to execute both files init.o and exit.o
This make file is important as we can’t compile out init func seperately
—————————-
revision 1.3
date: 2014/02/11 12:17:12;  author: raghav;  state: Exp;  lines: +14 -0
using module init function to insert the file inside the kernel and exit function is used to remove the file from kernel
Make sure dont use the same function name as init and exit are built in name and already defined inside kernels else it will create a problem
—————————-
revision 1.2
date: 2014/02/11 12:12:17;  author: raghav;  state: Exp;  lines: +2 -1
Inclluding linux/module.h and linux/init.h
and including MODULE_LICENCE
—————————-
revision 1.1
date: 2014/02/11 12:10:44;  author: raghav;  state: Exp;
Initial revision
=============================================================================
RCS file: clean.c,v
Working file: clean.c
head: 1.2
branch:
locks: strict
raghav: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
included the unregister_chrdev_region to unregister the device
to do so we need the major minor number.
which we’ll get from the first argv of alloc_chrdev_region
as i am using seperate files so , i have to use this dev_t dev as a extern in exit function
—————————-
revision 1.2    locked by: raghav;
date: 2014/02/13 06:09:06;  author: raghav;  state: Exp;  lines: +3 -5
included the unregister_chrdev_region to unregister the driver, but here its return type is void
—————————-
revision 1.1
date: 2014/02/13 05:58:43;  author: raghav;  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>