use of dev->dev_t

Malte Vesper malte.vesper at postgrad.manchester.ac.uk
Tue Mar 17 17:46:13 EDT 2015



On 17/03/15 21:13, Greg KH wrote:
> On Tue, Mar 17, 2015 at 08:43:38PM +0000, Malte Vesper wrote:
>> Hi,
>> I am trying to write a driver that uses the MINOR(dev_t) to identify
>> cards. Since it is a PCI driver and I get pcidev->dev.dev_t anyway. I
>> thought about not bothering to store the minor number of the device.
>> However if I look at pcidev->dev.dev_t in the remove function (the
>> driver frameworks remove), I always get pcidev->dev.dev_t == 0.
> That dev_t is not for your use, sorry, it is for the driver core to use,
> if it needs/wants to for a class device.  A PCI driver should never need
> to be a char device, but if it does, you have to make your own calls to
> the character device core.
>
> What type of PCI device is this?  Why do you want to have a character
> device node for it?
>
> thanks,
>
> greg k-h
I want to do stream processing with a FPGA. I hoped that I could read 
the minor from that field after calling device_create().

As for the streaming bit the intended mode of operation is send a chunk, 
receive a processed chunk. Since the FPGA might do filtering the result 
might be smaller.
Also there is no random access, and once a bit of the returned data has 
been read, it can not be read again. The FPGA is more or less 
passthrough with some FIFO buffers.

This use model and other examples (there are a few PCIe FPGA drivers out 
there which do char device (i.e. Riffa)), led me to pick a char device.
Either way, the actual data transfer is handled solely by the device 
acting as a bus master (DMA).

Would you still recommend a block device driver type?
Is there an elegant way to get back at the MINOR() without storing it 
i.e. in the private data field (pci_set_drvdata).

Thanks,
Malte





More information about the Kernelnewbies mailing list