In several places in the kernel we find PCI_DEVID used like this: PCI_DEVID(dev->bus->number, dev->devfn) Add a "pci_dev_id(struct pci_dev *dev)" helper to simplify callers.
Unified · Split
| @@ -1338,7 +1338,7 @@ irq_hw_number_t pci_msi_domain_calc_hwirq(struct pci_dev *dev, · 1337 unmodified lines | |||
| 1338 | struct msi_desc *desc) | 1338 | struct msi_desc *desc) |
| 1339 | { | 1339 | { |
| 1340 | return (irq_hw_number_t)desc->msi_attrib.entry_nr | | 1340 | return (irq_hw_number_t)desc->msi_attrib.entry_nr | |
| 1341 | PCI_DEVID(dev->bus->number, dev->devfn) << 11 | | 1341 | pci_dev_id(dev) << 11 | |
| 1342 | (pci_domain_nr(dev->bus) & 0xFFFFFFFF) << 27; | 1342 | (pci_domain_nr(dev->bus) & 0xFFFFFFFF) << 27; |
| 1343 | } | 1343 | } |
| 1344 | 1344 | ||
| @@ -1508,7 +1508,7 @@ static int get_msi_id_cb(struct pci_dev *pdev, u16 alias, void *data) · 163 unmodified lines | |||
| 1508 | u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev) | 1508 | u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev) |
| 1509 | { | 1509 | { |
| 1510 | struct device_node *of_node; | 1510 | struct device_node *of_node; |
| 1511 | u32 rid = PCI_DEVID(pdev->bus->number, pdev->devfn); | 1511 | u32 rid = pci_dev_id(pdev); |
| 1512 | 1512 | ||
| 1513 | pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid); | 1513 | pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid); |
| 1514 | 1514 | ||
| @@ -1531,7 +1531,7 @@ u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev) · 16 unmodified lines | |||
| 1531 | struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev) | 1531 | struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev) |
| 1532 | { | 1532 | { |
| 1533 | struct irq_domain *dom; | 1533 | struct irq_domain *dom; |
| 1534 | u32 rid = PCI_DEVID(pdev->bus->number, pdev->devfn); | 1534 | u32 rid = pci_dev_id(pdev); |
| 1535 | 1535 | ||
| 1536 | pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid); | 1536 | pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid); |
| 1537 | dom = of_msi_map_get_device_domain(&pdev->dev, rid); | 1537 | dom = of_msi_map_get_device_domain(&pdev->dev, rid); |
| @@ -33,7 +33,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev, · 32 unmodified lines | |||
| 33 | struct pci_bus *bus; | 33 | struct pci_bus *bus; |
| 34 | int ret; | 34 | int ret; |
| 35 | 35 | ||
| 36 | ret = fn(pdev, PCI_DEVID(pdev->bus->number, pdev->devfn), data); | 36 | ret = fn(pdev, pci_dev_id(pdev), data); |
| 37 | if (ret) | 37 | if (ret) |
| 38 | return ret; | 38 | return ret; |
| 39 | 39 | ||
| @@ -88,9 +88,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev, · 48 unmodified lines | |||
| 88 | return ret; | 88 | return ret; |
| 89 | continue; | 89 | continue; |
| 90 | case PCI_EXP_TYPE_PCIE_BRIDGE: | 90 | case PCI_EXP_TYPE_PCIE_BRIDGE: |
| 91 | ret = fn(tmp, | 91 | ret = fn(tmp, pci_dev_id(tmp), data); |
| 92 | PCI_DEVID(tmp->bus->number, | ||
| 93 | tmp->devfn), data); | ||
| 94 | if (ret) | 92 | if (ret) |
| 95 | return ret; | 93 | return ret; |
| 96 | continue; | 94 | continue; |
| @@ -101,9 +99,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev, · 4 unmodified lines | |||
| 101 | PCI_DEVID(tmp->subordinate->number, | 99 | PCI_DEVID(tmp->subordinate->number, |
| 102 | PCI_DEVFN(0, 0)), data); | 100 | PCI_DEVFN(0, 0)), data); |
| 103 | else | 101 | else |
| 104 | ret = fn(tmp, | 102 | ret = fn(tmp, pci_dev_id(tmp), data); |
| 105 | PCI_DEVID(tmp->bus->number, | ||
| 106 | tmp->devfn), data); | ||
| 107 | if (ret) | 103 | if (ret) |
| 108 | return ret; | 104 | return ret; |
| 109 | } | 105 | } |
| @@ -596,6 +596,11 @@ struct pci_bus { · 595 unmodified lines | |||
| 596 | 596 | ||
| 597 | #define to_pci_bus(n) container_of(n, struct pci_bus, dev) | 597 | #define to_pci_bus(n) container_of(n, struct pci_bus, dev) |
| 598 | 598 | ||
| 599 | static inline u16 pci_dev_id(struct pci_dev *dev) | ||
| 600 | { | ||
| 601 | return PCI_DEVID(dev->bus->number, dev->devfn); | ||
| 602 | } | ||
| 603 | |||
| 599 | /* | 604 | /* |
| 600 | * Returns true if the PCI bus is root (behind host-PCI bridge), | 605 | * Returns true if the PCI bus is root (behind host-PCI bridge), |
| 601 | * false otherwise | 606 | * false otherwise |