LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 04-17-2008, 05:49 AM   #1
vijays
LQ Newbie
 
Registered: Apr 2008
Posts: 5

Rep: Reputation: 0
unable to register kernel module


Hi,

I am using linux 2.4.20 on mips malta board.
I am trying to insmod a kernel module , and it is not giving any error.
' lsmod ' is showing the new module, but module is not in the /proc/devices file.
I am using gcc version 3.3.1 and busy box version is v0.65.5

It seems 'register_chrdev' is not working.

I am using following Sample code.

int hello_init(void)
{
int ret=0;

printk(KERN_INFO "Hello world .\n");

/* A non 0 return means init_module failed; module can't be loaded */
ret = register_chrdev(TXC_LINUX_MAJOR,TXC_LINUX_DRIVER_N AME,&txc_fops);

if (ret < 0)
{
printk("<1>Registering %s Driver Failed\n",TXC_LINUX_DRIVER_NAME);

return ret;
}

return 0;

}

void hello_exit(void)
{
int ret=0;
ret = unregister_chrdev(TXC_LINUX_MAJOR,TXC_LINUX_DRIVER _NAME);

if(ret < 0 )
{
printk("<1>De-Registering %s Driver Failed\n",TXC_LINUX_DRIVER_NAME);
}

printk("<1>%s Driver Unloaded.\n",TXC_LINUX_DRIVER_NAME);

printk(KERN_INFO "Goodbye world .\n");
}


Also I am unable to see printk message on the console, and looked up into /var/log/ I found this folder empty. it seems that print is not enabled in the kernel image so how it can be enabled.

Thanks in advance to help me out.

Regards,
Vijay
 
Old 04-17-2008, 09:45 AM   #2
hiren_bhatt
Member
 
Registered: Oct 2005
Distribution: FC3,Debian
Posts: 127

Rep: Reputation: 15
Since you complete module code in not given, and only relevant code is there I am assuming few things.

First thing,I hope you have registered the init and exis functions using module_init/exit macros. More over generally the hello_init should be static.

Quote:
it seems that print is not enabled in the kernel image so how it can be enabled.
This should generally work, by default (if you have not modified the kernel). Check if the klogd and syslogd services are working. If yes then the kernel log should appear. To print to console the console log level should be same as you write it in printk. By default console log level is equal to <6> i.e Kernel_info.

If your module is loading correctly then, the message should come.

I hope the module is compiled properly! I dont see much problem with register_chrdev() except its good to have TXC_LINUX_MAJOR = 0. This is recommended and not necessary. Either a way if the Major number is in use then it will give you an error setting ret<0, which is fine.

I hope you first make sure is the module is loaded properly and then check for register_chrdev(). I am not sure when all possibilities you have all ready tried, if you have all ready tried these things and still doesnt work please provide more precise details of your module.

Hope this helps,
Regards.

Last edited by hiren_bhatt; 04-17-2008 at 09:49 AM.
 
Old 04-18-2008, 03:09 AM   #3
vijays
LQ Newbie
 
Registered: Apr 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks For reply,

Yes, I am using following macro.
module_init(hello_init);
module_exit(hello_exit);

I find that klogd and syslogd services are not enabled. How these can be enabled?
[Is it through 'make menuconfig'].

Also i tried with TXC_LINUX_MAJOR = 0. But no result.

------ Complete module code -------

MODULE_LICENSE("Dual BSD/GPL");

#define TXC_LINUX_MAJOR 0 // also tried with the different unused numbers
#define TXC_LINUX_DRIVER_NAME "txcHello"


int hello_init(void)
{
int ret=0;

printk(KERN_INFO "Hello world .\n");

ret = register_chrdev(TXC_LINUX_MAJOR,TXC_LINUX_DRIVER_NAME,&txc_fops);
if (ret < 0)
{
printk("<1>Registering %s Driver Failed\n",TXC_LINUX_DRIVER_NAME);
return ret;
}

return 0;

}

void hello_exit(void)
{
int ret=0;
ret = unregister_chrdev(TXC_LINUX_MAJOR,TXC_LINUX_DRIVER_NAME);
if(ret < 0 )
{
printk("<1>De-Registering %s Driver Failed\n",TXC_LINUX_DRIVER_NAME);
}
printk("<1>%s Driver Unloaded.\n",TXC_LINUX_DRIVER_NAME);
printk(KERN_INFO "Goodbye world .\n");
}

module_init(hello_init);
module_exit(hello_exit);

-------------

'lsmod' lists this module in the loaded module list.
loadable module support is enabled in the kernel image. Using NFS.
Any additional option do I need to be enable for 'kernel module' support?


Regards
Vijay
 
Old 04-18-2008, 05:07 AM   #4
hiren_bhatt
Member
 
Registered: Oct 2005
Distribution: FC3,Debian
Posts: 127

Rep: Reputation: 15
If the module is compiled and loading correctly and if its just the log messages problem then,

klogd and syslogd are utilities and mostly it should be installed on you system. In that case it is just a matter of starting the services,
If its not installed you can download those packages from your distribution's repository and install them.

Starting service is little difference across distributions(e.g Fedora based distribution and Debian based dist), you can use GUI for starting service.

This is the most simple and standard way to solve your problem, if after enabling both the service still the module is loaded and you are not able to see any massages then possible we can try other things. You can also configure these demons to write log messages to particular file, but that is if you have such specific need.
 
Old 04-24-2008, 02:43 AM   #5
hiren_bhatt
Member
 
Registered: Oct 2005
Distribution: FC3,Debian
Posts: 127

Rep: Reputation: 15
Wondering if the problem is solved!!!, if so it would good for others if you can post the solution.
 
  


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
unable to build nvidia kernel module Cyber Maid Linux - Software 10 01-28-2007 07:44 AM
unable to remove kernel module........ dogslayer Linux - Software 6 03-27-2006 01:26 AM
Unable to build NVIDIA kernel module / determin kernel version Night Ink Fedora 2 05-31-2004 05:54 PM
Unable to load kernel module nvidia.o innovest_11 Linux - Newbie 2 02-01-2004 12:08 PM
Unable to unload eepro100 module in Kernel 2.6 simjii Linux - General 0 12-09-2003 12:50 AM


All times are GMT -5. The time now is 12:42 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