LKM register_chrdev_region(..) problem
I just installed Fedora Core 5, and I updated the kernel to 2.6.16-1.2080_FC5 to get the latest kernel build files, and the system reboots fine. Then I wrote a real simple "Hello World" Linkable Kernel Module. It compiles fine but when it is inserted, I get an error saying that "insmod: error inserting 'HelloWorld.ko': -1 Device or resource busy" even though I use an unused static major or a dynamically created one. The error is generated by the register_chardev_region(dev, 1, "Hello"). See code below. The /var/log/messages indicates that the driver load failed with -16.
Can u help me in this?
int init_module(void)
{
int result = 0;
printk(KERN_ERR "Hello Loading...\n");
// Register device with static MAJOR number
result = register_chrdev_region(MKDEV(100, 0), 1, "Hello");
if(result < 0)
{
printk(KERN_ERR "Hello Driver Load Failed! (%d) \n", result);
return result;
}
printk(KERN_ERR "Hello, World\n");
return 0;
}
Reply With Quote
|