EmbLogic's Blog

Unregistering a character device driver from device table

There are some points which we have to note down while working in character device driver:
1. The second argument of unregister_chrdev_region function means the number of devices to unregister from the device table ….  should be matched with the third argument of alloc_chrdev_region function. Else the driver entry will not remove from the device table.

RCS file: clean.c,v
Working file: clean.c
head: 1.5
branch:
locks: strict
raghav: 1.5
access list:
symbolic names:
keyword substitution: kv
total revisions: 5;    selected revisions: 5
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.5    locked by: raghav;
date: 2014/02/13 11:20:48;  author: raghav;  state: Exp;  lines: +2 -0
adding kfree function to free the allocated memory of struct sculldev after removing and un registering the device
—————————-
revision 1.4
date: 2014/02/13 10:19:28;  author: raghav;  state: Exp;  lines: +1 -1
Error detected: In the second argument of unregister_chrdev_region func() we have to input only that number of drivers which we have registered.
suppose if we have register our driver for 10 devices then in the unregister fun() we have to unregister 10 devices i.e give 10 in the second argument of unregister function.
—————————-
revision 1.3
date: 2014/02/13 10:18:05;  author: raghav;  state: Exp;  lines: +6 -5
Error in un registering the driver from the driver table
—————————-
revision 1.2
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>