int ret, cap, err;
        u16 ctl;
 
-       cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
+       cap = pci_pcie_cap(pdev);
        if (!cap)
                return 0;
 
 {
        struct pci_dev *bridge = mgp->pdev->bus->self;
        struct device *dev = &mgp->pdev->dev;
-       unsigned cap;
+       int cap;
        unsigned err_cap;
        u16 val;
        u8 ext_type;
                return;
 
        /* check that the bridge is a root port */
-       cap = pci_find_capability(bridge, PCI_CAP_ID_EXP);
+       cap = pci_pcie_cap(bridge);
        pci_read_config_word(bridge, cap + PCI_CAP_FLAGS, &val);
        ext_type = (val & PCI_EXP_FLAGS_TYPE) >> 4;
        if (ext_type != PCI_EXP_TYPE_ROOT_PORT) {
                                                " to force ECRC\n");
                                        return;
                                }
-                               cap =
-                                   pci_find_capability(bridge, PCI_CAP_ID_EXP);
+                               cap = pci_pcie_cap(bridge);
                                pci_read_config_word(bridge,
                                                     cap + PCI_CAP_FLAGS, &val);
                                ext_type = (val & PCI_EXP_FLAGS_TYPE) >> 4;
                int link_width, exp_cap;
                u16 lnk;
 
-               exp_cap = pci_find_capability(mgp->pdev, PCI_CAP_ID_EXP);
+               exp_cap = pci_pcie_cap(mgp->pdev);
                pci_read_config_word(mgp->pdev, exp_cap + PCI_EXP_LNKSTA, &lnk);
                link_width = (lnk >> 4) & 0x3f;