EmbLogic's Blog

Initializing a driver using alloc_chrdev_region()

RCS file: header.h,v
Working file: header.h
head: 1.10
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 10; selected revisions: 10
description:
this is header file

here various header files are included such as module param.h init.h cdev.h slab.h and many others
—————————
revision 1.10
date: 2015/04/24 12:36:40; author: psingh; state: Exp; lines: +1

Here module author,module licence and module description is defined

 

—————————

RCS file: declaration.h,v
Working file: declaration.h
head: 1.6
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 6; selected revisions: 6
description:
—————————-
revision 1.6
date: 2015/04/25 00:38:02; author: psingh; state: Exp; lines: +6 -6
This is declaration.h…
here declaration of struct qset is defined
here declaration of struct Dev is also defined
and a structure variable of type Dev is also defined which contains the element *qset and predefined structure cdev as mentioned in cdev.h…

============================================================================

RCS file: fopr.h,v
Working file: fopr.h
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
—————————-
revision 1.1
date: 2015/04/25 00:38:05; author: psingh; state: Exp;
Initial revision
Here file operation structure is taken and declared as extern…
=============================================================================

RCS file: init.c,v
Working file: init.c
head: 1.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 2; selected revisions: 2

date: 2015/04/24 10:54:2; author: psingh; state: Exp; lines: +1 -1
Here initalization of module is done using alloc_chrdev_region
after that memory will be allocated by kernel using kmalloc()
—————————
revision 1.6
date: 2015/04/24 10:53:1; author: psingh; state: Exp; lines: +4 -5
cdev structure is initialized and its memory is made NULL by using memset
after that cdev owner and file operation is declared and the addition of device table is done using cdev_add()

————————
=============================================================================

RCS file: clean.c,v
Working file: clean.c
head: 1.2
branch:p
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 2; selected revisions: 2
description:
this is cleanup function

revision 1.2
date: 2015/04/24 10:36:12; author: psingh; state: Exp; lines: +3 -1
first cdev_del will remove the device table from the driver module
after that kfree will free the memory allocated to the structure pointer as defined to the strcut Dev..
then unregisteration of the module will be carried by using unregister_chrdev_region

—————————-
revision 1.1
date: 2015/04/24 10:12:13; author: psingh; 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>