From your question, I assume this is a hardware module writing directly into a memory buffer. You will always need an intermediate memory buffer on the way to the file, but there are several ways to manage this in your device driver.
The simplest case is to implement a character device driver, which returns the data to userspace via a read operation. Your userspace application that writes to the file can then be as simple as cat
. Your module will write into a memory buffer allocated by your driver, and the read
method will copy data from this buffer to the userspace buffer. This is covered by DMA-Mapping.txt
in the kernel documentation and in Linux Device Drivers (LDD).
If the data rate is high (where high is relative to the performance of the device), you'll need to consider a more advanced read operation, where you lock the pages of the read
request into memory, and the module writes directly to those pages. This is more complicated, and the documentation in LDD on this area is quite old. I'd advise studying the source of the video capture drivers in the kernel to understand this.
If your driver has more sorts of communication to carry out, you may want to use Netlink.