Re: Major number changes after each insmod

On December 1, 2010 05:12, in comp.os.linux.development.system,
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");
But the value of dev changes each time I do a new rmmod/insmod: 254, 253,
So how can match it with mknod ?
mknod /dev/MyDev c 254 0
Right now I need to do it manually each time.

Isn't that what the udev subsystem is for? To dynamically create /dev node
entries as drivers are loaded and unloaded?

Can't I fix the major number in my driver initialization ?

Sure. Talk with the LIANA about allocating a permanent major device number
(or use one from the 'experimental' range, but only in your development
environment), and hardcode that major number into your driver. Then, you
make a single, permanent device node using mknod rather than having udev
make it for you.

Please note that, AFAICT, the preferred way to go is dynamic major node
numbers and udev; I doubt that LIANA will provide you with a fixed major
node number.

PS: with usenet getting increasingly sidelined, what is a good forum to
ask about general linux driver development ?

Sorry, I can't help you there.
Have you asked on the linux kernel developers IRC line, or at kernelnewbies?

Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
Me: | Just Linux:
---------- Slackware - Because I know what I'm doing. ------


Relevant Pages