LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 05-07-2009, 01:41 PM   #1
zman2245
LQ Newbie
 
Registered: Mar 2009
Location: San Francisco, CA
Posts: 26

Rep: Reputation: 15
rmmod not deleting module from /proc/devices


Hello:

I am writing a simple character device driver (code so far given below). I build the .ko file and insmod it. I can then see that the module is included in /proc/devices. However, after I do an rmmod on the module, the name remains in /proc/devices! Should this happen?

I did some google searching and it seems to me that /proc/devices should no longer show the module. lsmod no longer shows it, and I think I am using the chrdev APIs correctly.

Thanks,
Zack

1 #include <linux/types.h>
2 #include <linux/module.h>
3 #include <linux/init.h>
4 #include <linux/fs.h>
5 MODULE_LICENSE("Dual BSD/GPL");
6
7
8 static int kfa_init(void)
9 {
10 dev_t dev_num;
11 u32 status = 0;
12
13 status = alloc_chrdev_region(&dev_num, 0, 1, "kfa");
14 if (status < 0) {
15 printk("<0> An error occurred allocating dev numbers\n");
16 }
17
18 printk("<0> Hello! kfa_init() called!\n");
19
20 return (0);
21 }
22
23 static void kfa_fini(void)
24 {
25 unregister_chrdev_region(0, 1);
26 printk("<0> kfa_fini called! Exiting....\n");
27 }
28
29 module_init(kfa_init);
30 module_exit(kfa_fini);
 
Old 09-14-2012, 05:55 AM   #2
milohoffman
LQ Newbie
 
Registered: Sep 2012
Posts: 1

Rep: Reputation: Disabled
you have write something like this:

#include <linux/types.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>
MODULE_LICENSE("Dual BSD/GPL");

static dev_t dev_num;

static int kfa_init(void)
{
u32 status = 0;

status = alloc_chrdev_region(&dev_num, 0, 1, "kfa");
if (status < 0) {
printk("<0> An error occurred allocating dev numbers\n");
}

printk("<0> Hello! kfa_init() called!\n");

return (0);
}

static void kfa_fini(void)
{
unregister_chrdev_region(dev_num, 1);
printk("<0> kfa_fini called! Exiting....\n");
}

module_init(kfa_init);
module_exit(kfa_fini);
 
  


Reply



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
USB2 storage devices not working unless I rmmod ehci_hcd davecs Linux - Hardware 3 03-17-2007 03:57 PM
Linux 2.6 PCI driver module causing kernel panic on remove (rmmod) briek Linux - Software 2 09-18-2006 10:04 AM
Correlation between /proc/devices and /proc/modules ColinLadyka Linux - General 1 02-13-2006 05:25 PM
making sys call ex:insmod,rmmod from function in user module shashishankar_h Linux - General 1 09-01-2005 12:36 AM
nothing in /proc/pci and not finding devices naughtymutt Linux - Hardware 0 10-27-2002 10:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:58 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
Open Source Consulting | Domain Registration