svn commit: r222102 - head/sys/dev/cxgbe

Navdeep Parhar np at FreeBSD.org
Thu May 19 19:37:41 UTC 2011


Author: np
Date: Thu May 19 19:37:41 2011
New Revision: 222102
URL: http://svn.freebsd.org/changeset/base/222102

Log:
  Simplify t4_os_find_pci_capability.
  
  MFC after:	3 days

Modified:
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c	Thu May 19 17:24:53 2011	(r222101)
+++ head/sys/dev/cxgbe/t4_main.c	Thu May 19 19:37:41 2011	(r222102)
@@ -3212,45 +3212,12 @@ filter_rpl(struct adapter *sc, const str
 	}
 }
 
-/* XXX: use pci_find_cap */
 int
 t4_os_find_pci_capability(struct adapter *sc, int cap)
 {
-	device_t dev;
-	struct pci_devinfo *dinfo;
-	pcicfgregs *cfg;
-	uint32_t status;
-	uint8_t ptr;
-
-	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);
+	int i;
 
-	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);
+	return (pci_find_cap(sc->dev, cap, &i) == 0 ? i : 0);
 }
 
 int


More information about the svn-src-head mailing list