An example is given below:
[root@axis-00408c012351 /dev]192# ls -als
0 cr--r--r-- 1 root root 61, 0 Jan 20 2008 cam0
0 cr--r--r-- 1 root root 61, 1 Jan 20 2008 cam1
0 cr--r--r-- 1 root root 61, 2 Jan 20 2008 cam2
0 cr--r--r-- 1 root root 61, 3 Jan 20 2008 cam3
0 cr--r--r-- 1 root root 61, 32 Jan 20 2008 camquad
0 crw-rw-rw- 1 root root 91, 0 Jan 20 2008 can0
0 crw-rw-rw- 1 root root 91, 1 Jan 20 2008 can1
0 crw-rw-rw- 1 root root 91, 2 Jan 20 2008 can2
0 crw-r--r-- 1 root root 90, 0 Jan 20 2008 cflash0
0 crw-r--r-- 1 root root 90, 2 Jan 20 2008 cflash1
0 crw-r--r-- 1 root root 90, 4 Jan 20 2008 cflash2
0 crw-r--r-- 1 root root 90, 6 Jan 20 2008 cflash3
0 crw-r--r-- 1 root root 90, 8 Jan 20 2008 cflash4
0 crw-r--r-- 1 root root 90, 10 Jan 20 2008 cflash5
0 crw------- 1 root tty 5, 1 Jan 1 00:00 console
0 crw-r--r-- 1 root root 122, 0 Jan 20 2008 eeprom
0 crw-rw---- 1 root root 193, 0 Jan 20 2008 event
When you look to column 6 and 7 in the above given table, you will see that column 6 represents the major device number and column 7 represents the minor device number.
Since I'm working mainly on the I2C driver on the FoxBoard, I was interested in how this driver was set up.
At the same time, I was reading the (very interesting) book Linux Device Drivers and while reading it, I was especially interested in the chapter handling the devices major and minor numbers.
There was a very interesting statement done, which said to use dynamic device number allocation, in stead of doing it statically.
It was not only the direction to go, it also has the following benefits:
- The system will take care of the major and minor number allocated at runtime
- You will not "clash" with a driver which has the same major and minor number
- You're safe for the future
I wrote a whole chapter on my Wiki pages, explaining what I have done to achieve this. Not only was it a challenge, it forced me to learn the mechanisms which were (and still are) used to build the flash images for the FoxBoard.
I don't want to fall into repetition, you can read the whole story here.
After you've done all necessary changes, you will see the effect when restarting the FoxBoard. At a certain moment, you will see that a dynamic major and minor number is requested to the Linux kernel for the device.
You will see that not the number 123 is given as major device number (as is the case with the static situation in the FoxBoard I2C code), but the number 254.
Here's the output when performing an ls -als in the directory /var/dev:
[root@axis-00408c012351 /var/dev]132# ls -als
0 drwxr-xr-x 2 root root 60 Jan 1 00:00 .
0 drwxr-xr-x 10 root root 200 Jan 1 00:00 ..
0 crw-r--r-- 1 root root 254, 0 Jan 1 00:00 i2c
This way, you are sure you won't "clash" with some other driver using the same major and minor numbers and you're sure you're following the advice of authorities in the Linux domain (writers of the Linux Device Driver book).