History

PCI: Add pci_dev_id() helper

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.

Heiner Kallweit committed 7 years ago

Commit 4e544ba1 parent e0547c83 files · +11 −10Browse files

Unified · Split

3 files
  1. drivers/pci/msi.c +3 −3
  2. drivers/pci/search.c +3 −7
  3. include/linux/pci.h +5 −0
drivers/pci/msi.c+3−3
@@ -1338,7 +1338,7 @@ irq_hw_number_t pci_msi_domain_calc_hwirq(struct pci_dev *dev, · 1337 unmodified lines
13381338 struct msi_desc *desc)
13391339 {
13401340 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 |
13421342 (pci_domain_nr(dev->bus) & 0xFFFFFFFF) << 27;
13431343 }
13441344
@@ -1508,7 +1508,7 @@ static int get_msi_id_cb(struct pci_dev *pdev, u16 alias, void *data) · 163 unmodified lines
15081508 u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev)
15091509 {
15101510 struct device_node *of_node;
1511− u32 rid = PCI_DEVID(pdev->bus->number, pdev->devfn);
1511+ u32 rid = pci_dev_id(pdev);
15121512
15131513 pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid);
15141514
@@ -1531,7 +1531,7 @@ u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev) · 16 unmodified lines
15311531 struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev)
15321532 {
15331533 struct irq_domain *dom;
1534− u32 rid = PCI_DEVID(pdev->bus->number, pdev->devfn);
1534+ u32 rid = pci_dev_id(pdev);
15351535
15361536 pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid);
15371537 dom = of_msi_map_get_device_domain(&pdev->dev, rid);
drivers/pci/search.c+3−7
@@ -33,7 +33,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev, · 32 unmodified lines
3333 struct pci_bus *bus;
3434 int ret;
3535
36− ret = fn(pdev, PCI_DEVID(pdev->bus->number, pdev->devfn), data);
36+ ret = fn(pdev, pci_dev_id(pdev), data);
3737 if (ret)
3838 return ret;
3939
@@ -88,9 +88,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev, · 48 unmodified lines
8888 return ret;
8989 continue;
9090 case PCI_EXP_TYPE_PCIE_BRIDGE:
91− ret = fn(tmp,
92− PCI_DEVID(tmp->bus->number,
93− tmp->devfn), data);
91+ ret = fn(tmp, pci_dev_id(tmp), data);
9492 if (ret)
9593 return ret;
9694 continue;
@@ -101,9 +99,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev, · 4 unmodified lines
10199 PCI_DEVID(tmp->subordinate->number,
102100 PCI_DEVFN(0, 0)), data);
103101 else
104− ret = fn(tmp,
105− PCI_DEVID(tmp->bus->number,
106− tmp->devfn), data);
102+ ret = fn(tmp, pci_dev_id(tmp), data);
107103 if (ret)
108104 return ret;
109105 }
include/linux/pci.h+5−0
@@ -596,6 +596,11 @@ struct pci_bus { · 595 unmodified lines
596596
597597 #define to_pci_bus(n) container_of(n, struct pci_bus, dev)
598598
599+static inline u16 pci_dev_id(struct pci_dev *dev)
600+{
601+ return PCI_DEVID(dev->bus->number, dev->devfn);
602+}
603+
599604 /*
600605 * Returns true if the PCI bus is root (behind host-PCI bridge),
601606 * false otherwise

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t