I would THANK if you answer my doubts in DETAILS please.
Here's a sample code to create a device:
1. I didn't understand the first line! In the second and third lines, a device is created using the given minor and major numbers (I am sure this is a static allocation) and register_chrdev creates multiple instances of it.
what about the first line? I can't understand what that if(major number) doing there, what's so relevant to it?
2. if the major number is not created it goes to while n creates a dynamic major number. Major number means the driver ID to which the device associates with, OK? but so far, how would the kernel know about which driver it shall connect it? it just allocates one dynamically!
3.
Quote:
register_chrdev_region works well if you know ahead of time exactly which device numbers you want. Often, However, you will not know which major numbers your device will use.
!!! what's so relevant between major number and device numbers in 3? major number is the driver number the device associates with and it's not the device number (that's minor number). So, why 3 notes that?
4. Why do we need a seperate script to read /proc/devices file?
Please post what Operating System and version you have and what Shell (or other language) this is? The syntax is alien to me because there are no space characters between commands and code block brackets.
The syntax is alien to me because there are no space characters between commands and code block brackets.
This alien language is undoubtedly C and this is part of a Linux device driver code.
@dr_mabuse The first line is a very common C shortcut for
or the equivalent
Beyond that, have a look at what alloc_chrdev_region is doing to investigate your second question. Chapter 3 of this book might help you.
hi, dear all
Now I have a problem on the minor number of device.
I have many sd disks. The sd driver will create many minor numbers for these disks when attached.
But the sd driver may be not remove thest minor number when detached.
The minor number will become very big If I attach and... (2 Replies)
Hey!
I'm trying to figure out a sollution for a problem I have at my company with an Iomega MiniMax 500 GB USB disk.
If i run cat /proc/bus/usb/devices
I get this information:
T: Bus=01 Lev=02 Prnt=04 Port=00 Cnt=01 Dev#= 5 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00... (2 Replies)