Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-21-2012, 05:42 AM   #1
LQ Newbie
Registered: Jun 2012
Location: Bangalore
Posts: 2

Rep: Reputation: Disabled
Post Unregistering a character Device driver from /proc/devices

Hi all, i'm reading linux device drivers,
and i'm creating a character driver.

I alloc a chrdev region

how can i deallocate it ? I tried with
unregister_chrdev_region but it does work only for
statically allocated devices.

i want to deallocate it so that only a single major number is assigned to my driver and

cat /dev/devices | grep $dev_name
returns no more than 1 line.
Old 06-21-2012, 10:22 AM   #2
LQ Newbie
Registered: May 2012
Posts: 5

Rep: Reputation: Disabled
This is the format for alloc_chrdev_region:
int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, const char *name)
It will store the Major/Minor number information at the address specified by dev. This ought to be a static variable, as it will be used again to unregister.
baseminor is the starting minor number (probably 0).
count is the number of potential character devices (minor numbers will be baseminor through count - 1)
name is the name of the driver that will appear in /proc/devices (not /dev/devices)

NOTE: You should make sure the return value is 0 before moving on in the driver and exit if it isn't.

To unregister, use unregister_chrdev_region:
void unregister_chrdev_region(dev_t from, unsigned count)
from should be the value stored by alloc_chrdev_region (the actual value this time, not a pointer).
count is the same count from alloc_chrdev_region.

NOTE: Regardless of what you specify for count, using:
cat /proc/devices | grep $dev_name
should always return one line (as long $dev_name isn't a substring of some other device's name).
1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
palm device listed in /proc/bus/usb/devices, but not in lsusb output carltm Linux - Hardware 2 09-09-2010 07:33 AM
/proc/bus/usb/devices and unassigned driver gromot Linux - Hardware 0 12-17-2009 08:26 AM
proc/bus/usb/devices no driver knobby67 Linux - Hardware 8 06-19-2008 03:43 AM
Unregistering a driver linked into the kernel Jesus Lopez Linux - Kernel 5 06-28-2007 11:26 AM
No PCMCIA Driver in /proc/devices??? 10xOXR Linux - Laptop and Netbook 1 09-09-2005 02:26 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:54 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration