Need help filling in some knowledge gaps on driver use in user applications. I have a digital IO driver. I compile the driver and install it on boot with modprobe and when i check in /dev I can see /dev/digitalIOa. If i check lsmod i can see digitalIO is loaded.

From what I've been reading (here, there), the driver is loaded, as lsmod shows, and a device file has been created in /dev/ named digitalIOa.

1st knowledge gap: So it looks like the driver's init_module function simply created a default device file for me and named it digitalIOa?
2nd knowledge gap: The driver's documentation specifies it can support up to 4 devices (digitalIOa, digitalIOb, digitalIOc, digitalIOd) i believe based upon the number of chips present. I only have one, thus I only get digitalIOa. I was under the impression that a single driver, e.g. digitalIO can/should support many devices (device files?) using the driver's major number and assigning them minor numbers. So, in this context is the fact that the, what I am assuming is a default device file, named digitalIOa just a coincidence or does this driver in fact only support creating a single device file (which doesn't seem likely)?

3rd knowledge gap: digitalIO driver's API that my user application links to has expected function calls like: write_byte, read_byte, etc, but I do not see anything like "add device()". The file ops structure contains open() but I'm failing to understand how to use this. I tried a manual approach to get things moving by logging on to my target and issuing mknod calls with the major number of digitalIO listed in /dev and a minor number and gave the device files names i wanted. they created just fine. The user application fails to open the device files I created. I do not recall the error it gave me but if someone thinks that the manual approach i used should have worked I can edit the post and add the error.

I want to create more device files in a sub directory of dev e.g. /dev/myuserapp/myDigiHello_1, /dev/myuserapp/myDigiHello_2, /dev/myuserapp/myDigiHello_n. Need a some direction for getting the user application to open up these device files for use.

  • Your questions can't be answered without knowing this driver. It's true that the same driver can, in principle, manage several devices, and each device can be specified by the minor number. However your driver obviously refuses to deal with the minor numbers that you created. You need to find out what minor numbers it accepts. With a little luck, the driver issues messages to the kernel message buffer (dmesg command) that help you clarify this, or it has a debug function that can be enabled with a modprobe parameter; see the output of modinfo or the driver's documentation for details. Mar 23 '21 at 2:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.