git: 762d32354a18 - main - cxgb(4): Use routines from pci(9) instead of hand rolled equivalents.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 14 Feb 2025 06:39:05 UTC
The branch main has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=762d32354a18517c28933ddc29f9d3d855e450b1 commit 762d32354a18517c28933ddc29f9d3d855e450b1 Author: Navdeep Parhar <np@FreeBSD.org> AuthorDate: 2024-12-09 00:05:33 +0000 Commit: Navdeep Parhar <np@FreeBSD.org> CommitDate: 2025-02-14 04:44:23 +0000 cxgb(4): Use routines from pci(9) instead of hand rolled equivalents. There is no need to include private PCI headers in the driver. MFC after: 1 week Sponsored by: Chelsio Communications --- sys/dev/cxgb/cxgb_main.c | 55 +++++------------------------------------------- 1 file changed, 5 insertions(+), 50 deletions(-) diff --git a/sys/dev/cxgb/cxgb_main.c b/sys/dev/cxgb/cxgb_main.c index a19483c7cbbf..882d1c6cc4a4 100644 --- a/sys/dev/cxgb/cxgb_main.c +++ b/sys/dev/cxgb/cxgb_main.c @@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE. #include <sys/kernel.h> #include <sys/bus.h> #include <sys/module.h> -#include <sys/pciio.h> #include <sys/conf.h> #include <machine/bus.h> #include <machine/resource.h> @@ -76,7 +75,6 @@ POSSIBILITY OF SUCH DAMAGE. #include <dev/pci/pcireg.h> #include <dev/pci/pcivar.h> -#include <dev/pci/pci_private.h> #include <cxgb_include.h> @@ -1137,66 +1135,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); }