Re: Major number changes after each insmod



On Wed, 01 Dec 2010 11:12:44 +0100, Guillaume Dargaud
<use_the_contact_form@xxxxxxxxxxxxxxxx> wrote:

Hello all,

I'm working on my first 'real' driver for linux (I've done libusb and other
usermode drivers before) and I have some basic questions.

First in the init of the module, I do:
rc = alloc_chrdev_region(&dev,minor,nr_devs,"MyDev");
major=MAJOR(dev);
But the value of dev changes each time I do a new rmmod/insmod: 254, 253,
etc...
So how can match it with mknod ?
mknod /dev/MyDev c 254 0
Right now I need to do it manually each time.
Can't I fix the major number in my driver initialization ?

My load scripts get the major number from /proc/devices. This is left
over from the pre-udev days. I don't know what the official approach
is these days.

http://www.tahomatech.com/downloads/drivers/linux_2.6/pci/x86/files/hardcopy/ihcp_install-2.6

Search for "if [ $1 = load ]" These scripts are pretty clunky -
should make them easier to read :)

Bill
--
William D Waddington
william.waddington@xxxxxxxxxx
"Even bugs...are unexpected signposts on
the long road of creativity..." - Ken Burtch
.



Relevant Pages

  • Re: Major number changes after each insmod
    ... So how can match it with mknod? ... Isn't that what the udev subsystem is for? ... and hardcode that major number into your driver. ... ask about general linux driver development? ...
    (comp.os.linux.development.system)
  • Re: Major number changes after each insmod
    ... So how can match it with mknod? ... Isn't that what the udev subsystem is for? ... and hardcode that major number into your driver. ... ask about general linux driver development? ...
    (comp.os.linux.development.system)
  • Major number changes after each insmod
    ... I'm working on my first 'real' driver for linux (I've done libusb and other ... First in the init of the module, ... So how can match it with mknod? ... Can't I fix the major number in my driver initialization? ...
    (comp.os.linux.development.system)
  • How to associate a driver with a new device?
    ... I am having a problem in associating a driver with a new device, ... First, I create a new device with mknod, named /dev/lpx. ... It has to be like the /dev/lp device, the parallel port. ...
    (comp.os.minix)
  • Re: [patch 5/3] fastboot: sync the async execution before late_initcall and move level 6s (sync) fir
    ... wouldn't hold up the main init process. ... being probed -- the driver core won't allow two threads to probe the ... Perhaps a better approach would be to make the device driver ... initcalls before there are any devices for their probe routines to ...
    (Linux-Kernel)