register_chrdev_region

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
   I am using the function register_chrdev_region to create 4
devices.But while inserting it is inserting.And i am able to see only
one device in /proc/devices and after removing the module when i try to
see the /proc/devices it is comming as segmentation fault.

I am listing the code below.Will you please tell me wht is wrong with
me.



#ifndef __KERNEL__
	#define __KERNEL__
#endif

#ifndef MODULE
	#define MODULE
#endif

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>

MODULE_AUTHOR("RAJA");
MODULE_DESCRIPTION("SCULL DEVICE 1");
MODULE_LICENSE("GPL");

#define DEVICE_NAME "scull"
#define NO_OF_DEVICES_REQUIRED 5
dev_t devNo;
static int __init init_module1(void);
static void __exit exit_module1(void);

static int __init init_module1()
{
	printk("Entered Into init function for module1");
	int result = register_chrdev_region(0,NO_OF_DEVICES_REQUIRED,DEVICE_NAME);
	if(result)
		printk("Unable To Create Region\n");
	else
		printk("Region Created\n");
	devNo = MKDEV(0,0);
	printk("Exited From init function for module1");
	return 0;
}

static void __exit exit_module1()
{
	printk("Entered Into Exit function for module1");
	unregister_chrdev_region(devNo,NO_OF_DEVICES_REQUIRED);
	printk("Exited From Exit function for module1");
}

module_init(init_module1);
module_exit(exit_module1);




thanks in advance
raja



--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux