I have received a driver (PCAN driver for PCI card, using rtdm), that creates /dev/pcan0 and /dev/pcan1 is compiled as a netdev driver.
There are many facilities that come with this driver, but they are all targeted at a user-level program reading CAN messages. What I need however is to read these messages from a kernel module. The PCAN driver doesn't export any variables/functions which means it doesn't provide a kernel-level API for me to use.
I looked briefly at the code and reading from the /dev device and writing to it don't use copy_from_user
or copy_to_user
. Therefore, I thought it should be safe for me to open the /dev/pcan0 from my kernel module and read from it.
Now my question is, how do I open/read from a /dev device from a kernel module?
P.S. I want to read from the CAN bus from an RTAI real-time thread, do you think that would cause a problem (for example every read passing through linux kernel and thus breaking real-time conditions?)
Given that I was using RTDM, there were two options: