Hey Alexandru Juncu Thank you for your help again. Sorry about that mistake, I just didn't notice the forward address when using quick reply. It won't happen again. Best. 2012/2/12 Alexandru Juncu <alex.juncu@xxxxxxxxxx>: > 2012/2/12 hz hanks <hankshz@xxxxxxxxx>: >> Hey Alexandru Juncu >> >> Thank you so much! You are so helpful for me. >> >> As far as I'm concerned, the point that confuses me is the definition >> of ONE device driver. For example, I would consider a file of some >> source codes, that manipulate the GPIO and use misc_register to >> register as miscdevice, as one device driver. However, I know that it >> will share the major device number 10 with other device drivers such >> as AD/DA. So how kernel works like that? In other words, how kernel >> works with major/minor device number? For example, will the kernel >> allocate some specific resources to drivers with major number 4 >> because it knows those drivers are for Serial ports. How about the >> minor number, will the kernel care about that? > > Hello! > > First of all, you should always reply to the list, because when there > are 100 people rather than one, you have a bigger chance of getting an > answer. > > Is hard to define ONE device driver. Linux is a monolithic kernel. > It's one big code. But linux is also modular and you can have > dynamically loaded modules. But it's very flexible... you can have a > module (a .ko file) that is a driver for two devices (not going to > find this, but it could happend). > > You usually have one .ko for one device driver for one device. This > would mean one major. For example, a device driver for all the SATA > devices. > > [0] http://en.wikipedia.org/wiki/Monolithic_kernel >> >> Thank you again! >> >> 2012/2/12 Alexandru Juncu <alex.juncu@xxxxxxxxxx>: >>> 2012/2/12 hz hanks <hankshz@xxxxxxxxx>: >>>> Hi, all >>>> >>>> I have a question about major/minor device number. I know that one can >>>> use int register_chrdev_region(dev_t from, unsigned count, const char >>>> *name); to register a driver with a unique pair of major/minor device >>>> number. But what's the difference between two drivers: in one case >>>> they have same major device number but different minor device number; >>>> on another case they have different major device number but same minor >>>> device number. When I searched the Internet, it said that major device >>>> number is to identify the driver while the minor device number is to >>>> identify specific hardware. But I'm still confused because it seems >>>> legal to share the major device number with different drivers. >>>> >>>> Please help me!Thank you! >>> >>> Hello! >>> >>> I would redirect you to the /dev fs to do a long listing of its >>> contents and notice the pattern. >>> Devices with the same major, are usually handled by the same device >>> driver. If that device driver needs to handle several devices, it uses >>> an array of minors. >>> >>> Example: >>> >>> crw-rw---- 1 root dialout 4, 64 2011-12-12 16:25 ttyS0 >>> crw-rw---- 1 root dialout 4, 65 2011-12-12 16:25 ttyS1 >>> crw-rw---- 1 root dialout 4, 66 2011-12-12 16:25 ttyS2 >>> crw-rw---- 1 root dialout 4, 67 2011-12-12 16:25 ttyS3 >>> >>> Notice that all the Serial ports have the same major (4) but different >>> minors (64-67). If you do a "cat /proc/devices" you will notice that >>> the major 4 is registered by ttyS device driver. "ttyS" is the name >>> variable in the register_chrdev_region call. >>> >>> A device driver can register zero, one ore more majors. And for each >>> of that major, it can a number of minors (the count parameter in >>> register_chrdev_region). >>> >>> Two devices having the same minor but different majors is just a >>> coincidence, they have nothing in common. It's just an obvious thing >>> because a major has more minors so there will be more minors that >>> majors. >>> >>> Hope this helps. _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies