1

PCI/IOV: Use pci_dev_id() to simplify the code

When we have a struct pci_dev *, use pci_dev_id() instead of manually
composing the ID with PCI_DEVID() from dev->bus->number and dev->devfn.

[bhelgaas: commit log]
Link: https://lore.kernel.org/r/20230807134858.116051-4-wangxiongfeng2@huawei.com
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
Xiongfeng Wang 2023-08-07 21:48:58 +08:00 committed by Bjorn Helgaas
parent f7f7c3d615
commit 6f7dc30767

View File

@ -41,8 +41,7 @@ int pci_iov_vf_id(struct pci_dev *dev)
return -EINVAL; return -EINVAL;
pf = pci_physfn(dev); pf = pci_physfn(dev);
return (((dev->bus->number << 8) + dev->devfn) - return (pci_dev_id(dev) - (pci_dev_id(pf) + pf->sriov->offset)) /
((pf->bus->number << 8) + pf->devfn + pf->sriov->offset)) /
pf->sriov->stride; pf->sriov->stride;
} }
EXPORT_SYMBOL_GPL(pci_iov_vf_id); EXPORT_SYMBOL_GPL(pci_iov_vf_id);