LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 06-21-2012, 06:42 AM   #1
krishnateja
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
with
alloc_chrdev_region(&dev,minor_number,number_of_devs);

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, 11:22 AM   #2
ppoulsen
LQ Newbie
 
Registered: May 2012
Posts: 5

Rep: Reputation: Disabled
This is the format for alloc_chrdev_region:
Code:
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:
Code:
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:
Code:
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.
  


Reply


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 08:33 AM
/proc/bus/usb/devices and unassigned driver gromot Linux - Hardware 0 12-17-2009 09:26 AM
proc/bus/usb/devices no driver knobby67 Linux - Hardware 8 06-19-2008 04:43 AM
Unregistering a driver linked into the kernel Jesus Lopez Linux - Kernel 5 06-28-2007 12:26 PM
No PCMCIA Driver in /proc/devices??? 10xOXR Linux - Laptop and Netbook 1 09-09-2005 03:26 PM


All times are GMT -5. The time now is 08:29 AM.

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