提交 4e544bac 编写于 作者: H Heiner Kallweit 提交者: Bjorn Helgaas

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.
Signed-off-by: NHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
上级 e0547c81
...@@ -1338,7 +1338,7 @@ irq_hw_number_t pci_msi_domain_calc_hwirq(struct pci_dev *dev, ...@@ -1338,7 +1338,7 @@ irq_hw_number_t pci_msi_domain_calc_hwirq(struct pci_dev *dev,
struct msi_desc *desc) struct msi_desc *desc)
{ {
return (irq_hw_number_t)desc->msi_attrib.entry_nr | return (irq_hw_number_t)desc->msi_attrib.entry_nr |
PCI_DEVID(dev->bus->number, dev->devfn) << 11 | pci_dev_id(dev) << 11 |
(pci_domain_nr(dev->bus) & 0xFFFFFFFF) << 27; (pci_domain_nr(dev->bus) & 0xFFFFFFFF) << 27;
} }
...@@ -1508,7 +1508,7 @@ static int get_msi_id_cb(struct pci_dev *pdev, u16 alias, void *data) ...@@ -1508,7 +1508,7 @@ static int get_msi_id_cb(struct pci_dev *pdev, u16 alias, void *data)
u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev) u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev)
{ {
struct device_node *of_node; struct device_node *of_node;
u32 rid = PCI_DEVID(pdev->bus->number, pdev->devfn); u32 rid = pci_dev_id(pdev);
pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid); pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid);
...@@ -1531,7 +1531,7 @@ u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev) ...@@ -1531,7 +1531,7 @@ u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev)
struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev) struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev)
{ {
struct irq_domain *dom; struct irq_domain *dom;
u32 rid = PCI_DEVID(pdev->bus->number, pdev->devfn); u32 rid = pci_dev_id(pdev);
pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid); pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid);
dom = of_msi_map_get_device_domain(&pdev->dev, rid); dom = of_msi_map_get_device_domain(&pdev->dev, rid);
......
...@@ -33,7 +33,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev, ...@@ -33,7 +33,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev,
struct pci_bus *bus; struct pci_bus *bus;
int ret; int ret;
ret = fn(pdev, PCI_DEVID(pdev->bus->number, pdev->devfn), data); ret = fn(pdev, pci_dev_id(pdev), data);
if (ret) if (ret)
return ret; return ret;
...@@ -88,9 +88,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev, ...@@ -88,9 +88,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev,
return ret; return ret;
continue; continue;
case PCI_EXP_TYPE_PCIE_BRIDGE: case PCI_EXP_TYPE_PCIE_BRIDGE:
ret = fn(tmp, ret = fn(tmp, pci_dev_id(tmp), data);
PCI_DEVID(tmp->bus->number,
tmp->devfn), data);
if (ret) if (ret)
return ret; return ret;
continue; continue;
...@@ -101,9 +99,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev, ...@@ -101,9 +99,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev,
PCI_DEVID(tmp->subordinate->number, PCI_DEVID(tmp->subordinate->number,
PCI_DEVFN(0, 0)), data); PCI_DEVFN(0, 0)), data);
else else
ret = fn(tmp, ret = fn(tmp, pci_dev_id(tmp), data);
PCI_DEVID(tmp->bus->number,
tmp->devfn), data);
if (ret) if (ret)
return ret; return ret;
} }
......
...@@ -596,6 +596,11 @@ struct pci_bus { ...@@ -596,6 +596,11 @@ struct pci_bus {
#define to_pci_bus(n) container_of(n, struct pci_bus, dev) #define to_pci_bus(n) container_of(n, struct pci_bus, dev)
static inline u16 pci_dev_id(struct pci_dev *dev)
{
return PCI_DEVID(dev->bus->number, dev->devfn);
}
/* /*
* Returns true if the PCI bus is root (behind host-PCI bridge), * Returns true if the PCI bus is root (behind host-PCI bridge),
* false otherwise * false otherwise
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册