diff --git a/sys/dev/cxgb/cxgb_main.c b/sys/dev/cxgb/cxgb_main.c index c159849076c..4fc07dc126a 100644 --- a/sys/dev/cxgb/cxgb_main.c +++ b/sys/dev/cxgb/cxgb_main.c @@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include #include #include #include @@ -76,7 +75,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#include #include @@ -1138,66 +1136,23 @@ t3_fatal_err(struct adapter *sc) int t3_os_find_pci_capability(adapter_t *sc, int cap) { - device_t dev; - struct pci_devinfo *dinfo; - pcicfgregs *cfg; - uint32_t status; - uint8_t ptr; + int rc, reg = 0; - dev = sc->dev; - dinfo = device_get_ivars(dev); - cfg = &dinfo->cfg; - - status = pci_read_config(dev, PCIR_STATUS, 2); - if (!(status & PCIM_STATUS_CAPPRESENT)) - return (0); - - switch (cfg->hdrtype & PCIM_HDRTYPE) { - case 0: - case 1: - ptr = PCIR_CAP_PTR; - break; - case 2: - ptr = PCIR_CAP_PTR_2; - break; - default: - return (0); - break; - } - ptr = pci_read_config(dev, ptr, 1); - - while (ptr != 0) { - if (pci_read_config(dev, ptr + PCICAP_ID, 1) == cap) - return (ptr); - ptr = pci_read_config(dev, ptr + PCICAP_NEXTPTR, 1); - } - - return (0); + rc = pci_find_cap(sc->dev, cap, ®); + return (rc == 0 ? reg : 0); } int t3_os_pci_save_state(struct adapter *sc) { - device_t dev; - struct pci_devinfo *dinfo; - - dev = sc->dev; - dinfo = device_get_ivars(dev); - - pci_cfg_save(dev, dinfo, 0); + pci_save_state(sc->dev); return (0); } int t3_os_pci_restore_state(struct adapter *sc) { - device_t dev; - struct pci_devinfo *dinfo; - - dev = sc->dev; - dinfo = device_get_ivars(dev); - - pci_cfg_restore(dev, dinfo); + pci_restore_state(sc->dev); return (0); }