唯客微博客

专注于计算机,嵌入式领域的技术

0%

Linux驱动开发杂记(0x05) - 从pci_dev中获取总线、插槽、功能号

1
2
3
4
5
6
7
8
9
10
11
/*
* The PCI interface treats multi-function devices as independent
* devices. The slot/function address of each device is encoded
* in a single byte as follows:
*
* 7:3 = slot
* 2:0 = function
*/
#define PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))
#define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f)
#define PCI_FUNC(devfn) ((devfn) & 0x07)
1
2
3
4
5
struct pci_dev *dev

BusNumber = dev->bus->number;
SlotNumber = PCI_SLOT(dev->devfn);
FuncNumber = PCI_FUNC(dev->devfn);
-------------本文结束感谢您的阅读-------------

本文标题:Linux驱动开发杂记(0x05) - 从pci_dev中获取总线、插槽、功能号

文章作者:Vinx

发布时间:2018年11月08日 - 17:10

最后更新:2023年09月18日 - 11:10

原始链接:https://blog.vinkvin.com/post/5/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。