Date: Thu, 19 May 2011 19:37:41 +0000 (UTC) From: Navdeep Parhar <np@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r222102 - head/sys/dev/cxgbe Message-ID: <201105191937.p4JJbfIJ050574@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105191937.p4JJbfIJ050574>