That's exactly what alloc_chrdev_region is for. More information can be found at page 45 of LDD3: http://lwn.net/images/pdf/LDD3/ch03.pdf http://lxr.linux.no/linux+v2.6.28.3/fs/char_dev.c#L229
Cheers, Aviv On Wed, Feb 4, 2009 at 21:00, Kevin Wilson <[email protected]> wrote: > Hello, > > I want to write a simple device driver that will be controlled by IOCTLs > from user space. These IOCTLs will operate on /dev/myDev file , which will > represent a character device; I know that I can register a char device > by register_chrdev(MY_MAJOR_NUM, "mymodule", &mymodule_fops);The thing is > that this binds me to a specific major number for the device > (MY_MAJOR_NUM). > Suppose I will choose an arbitrary number, say 300, for MY_MAJOR_NUM. > Then,if this module will be run on a machine on which this major number is > held > by a diffrent driver (from let's say some different device) , than I will > be > unable to work with my driver ; since 300 (MY_MAJOR_NUM) > , which I had chosen as MY_MAJOR_NUM, will be held by a different > driver ,so register_chrdev() will fail. > > Is there a way to avoid using a specific major number and use some dynamic > mechanism which will give me a free char device for /dev/myDev? > > Rgs, > Rgs, > Kevin Wilson > > -- > To unsubscribe from this list: send an email with > "unsubscribe kernelnewbies" to [email protected] > Please read the FAQ at http://kernelnewbies.org/FAQ > >
