Commit 06a1cbaf authored by Kenji Kaneshige's avatar Kenji Kaneshige Committed by Jesse Barnes

PCI: use pci_pcie_cap() in pci core

Use pcie_cap() instead of pci_find_capability() to get PCIe capability
offset in PCI core code. This avoids unnecessary search in PCI
configuration space.
Signed-off-by: default avatarKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent d7b7e605
...@@ -741,8 +741,8 @@ static int pci_save_pcie_state(struct pci_dev *dev) ...@@ -741,8 +741,8 @@ static int pci_save_pcie_state(struct pci_dev *dev)
u16 *cap; u16 *cap;
u16 flags; u16 flags;
pos = pci_find_capability(dev, PCI_CAP_ID_EXP); pos = pci_pcie_cap(dev);
if (pos <= 0) if (!pos)
return 0; return 0;
save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP); save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP);
...@@ -1535,7 +1535,7 @@ void pci_enable_ari(struct pci_dev *dev) ...@@ -1535,7 +1535,7 @@ void pci_enable_ari(struct pci_dev *dev)
if (!bridge || !bridge->is_pcie) if (!bridge || !bridge->is_pcie)
return; return;
pos = pci_find_capability(bridge, PCI_CAP_ID_EXP); pos = pci_pcie_cap(bridge);
if (!pos) if (!pos)
return; return;
...@@ -2140,7 +2140,7 @@ static int pcie_flr(struct pci_dev *dev, int probe) ...@@ -2140,7 +2140,7 @@ static int pcie_flr(struct pci_dev *dev, int probe)
u32 cap; u32 cap;
u16 status; u16 status;
pos = pci_find_capability(dev, PCI_CAP_ID_EXP); pos = pci_pcie_cap(dev);
if (!pos) if (!pos)
return -ENOTTY; return -ENOTTY;
...@@ -2489,7 +2489,7 @@ int pcie_get_readrq(struct pci_dev *dev) ...@@ -2489,7 +2489,7 @@ int pcie_get_readrq(struct pci_dev *dev)
int ret, cap; int ret, cap;
u16 ctl; u16 ctl;
cap = pci_find_capability(dev, PCI_CAP_ID_EXP); cap = pci_pcie_cap(dev);
if (!cap) if (!cap)
return -EINVAL; return -EINVAL;
...@@ -2519,7 +2519,7 @@ int pcie_set_readrq(struct pci_dev *dev, int rq) ...@@ -2519,7 +2519,7 @@ int pcie_set_readrq(struct pci_dev *dev, int rq)
v = (ffs(rq) - 8) << 12; v = (ffs(rq) - 8) << 12;
cap = pci_find_capability(dev, PCI_CAP_ID_EXP); cap = pci_pcie_cap(dev);
if (!cap) if (!cap)
goto out; goto out;
......
...@@ -703,7 +703,7 @@ static void set_pcie_hotplug_bridge(struct pci_dev *pdev) ...@@ -703,7 +703,7 @@ static void set_pcie_hotplug_bridge(struct pci_dev *pdev)
u16 reg16; u16 reg16;
u32 reg32; u32 reg32;
pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); pos = pci_pcie_cap(pdev);
if (!pos) if (!pos)
return; return;
pci_read_config_word(pdev, pos + PCI_EXP_FLAGS, &reg16); pci_read_config_word(pdev, pos + PCI_EXP_FLAGS, &reg16);
...@@ -920,7 +920,7 @@ int pci_cfg_space_size(struct pci_dev *dev) ...@@ -920,7 +920,7 @@ int pci_cfg_space_size(struct pci_dev *dev)
if (class == PCI_CLASS_BRIDGE_HOST) if (class == PCI_CLASS_BRIDGE_HOST)
return pci_cfg_space_size_ext(dev); return pci_cfg_space_size_ext(dev);
pos = pci_find_capability(dev, PCI_CAP_ID_EXP); pos = pci_pcie_cap(dev);
if (!pos) { if (!pos) {
pos = pci_find_capability(dev, PCI_CAP_ID_PCIX); pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
if (!pos) if (!pos)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment