On Mon, Sep 26, 2005 at 11:00:43 +0530, raja wrote: > I am using kernel 2.6.11-1.1369_FC4. > and trying out register_chrdev_region() in a module as explained in book > Linux Device Drivers(LDD3) by rubini. > In that book It is given that to obtain one or more device numbers to > work with we hav to use register_chrdev_region > and i am trying to use that fun as follows.But i am unable to get the > desired result.And i am getting segmentation fault. > Will you please tell me wht is wrong with my code? If nothing else, you can't register major number of 0. There is some magic for it in the code, that will make things promptly fail. Choose an unused region manually or use alloc_chrdev_region (in which case you'll need udev daemon to create the device nodes). Also you must be passing in the devNo as the first argument, ie. it must be constructed by MKDEV(major, minor). And as optimization, devNo does not need to be a variable, because it's constant (unless you change it to alloc_chrdev_region). > [...] > 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; > } > [...] -- Jan 'Bulb' Hudec <bulb@xxxxxx>
Attachment:
signature.asc
Description: Digital signature