![](/img/trans.png)
[英]how to get pci_dev from file object in a driver's ioctl()?
[英]How to get bus/device/number from struct pci_dev?
https://elixir.bootlin.com/linux/latest/source/include/linux/pci.h#L286
在
struct pci_dev,
我只能看到总线和功能:
struct pci_bus *bus;
和
unsigned int devfn;
似乎没有(B / D / F)的设备信息?
和
struct pci_slot *slot;
在我的测试中,*插槽指向NULL,为什么?
我发现:
device = PCI_SLOT(pdev->devfn);
fn = PCI_FUNC(pdev->devfn);
https://elixir.bootlin.com/linux/v3.5/source/include/linux/pci.h#L31
Devfn在第7:3位包含设备编号,在第2:0位包含功能编号。 总线号在bus-> number中。 所以BDF是
bus->number << 8 | devfn
我不知道广告位; 也许您正在查看的设备是集成设备?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.