From owner-svn-src-head@freebsd.org Sat Jul 7 15:25:17 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 93E0E102B753; Sat, 7 Jul 2018 15:25:17 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4994C7C600; Sat, 7 Jul 2018 15:25:17 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2C4D0192CF; Sat, 7 Jul 2018 15:25:17 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w67FPHh1088931; Sat, 7 Jul 2018 15:25:17 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w67FPG1w088930; Sat, 7 Jul 2018 15:25:16 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201807071525.w67FPG1w088930@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Sat, 7 Jul 2018 15:25:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336067 - head/sys/dev/ath X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/dev/ath X-SVN-Commit-Revision: 336067 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Jul 2018 15:25:17 -0000 Author: imp Date: Sat Jul 7 15:25:16 2018 New Revision: 336067 URL: https://svnweb.freebsd.org/changeset/base/336067 Log: Switch to using new PCI_MATCH stuff. Modified: head/sys/dev/ath/if_ath_pci.c head/sys/dev/ath/if_ath_pci_devlist.h Modified: head/sys/dev/ath/if_ath_pci.c ============================================================================== --- head/sys/dev/ath/if_ath_pci.c Sat Jul 7 15:25:11 2018 (r336066) +++ head/sys/dev/ath/if_ath_pci.c Sat Jul 7 15:25:16 2018 (r336067) @@ -82,41 +82,12 @@ struct ath_pci_softc { void *sc_ih; /* interrupt handler */ }; -/* - * XXX eventually this should be some system level definition - * so modules will have probe/attach information like USB. - * But for now.. - */ -struct pci_device_id { - int vendor_id; - int device_id; +#define PCI_VDEVICE(v, d) \ + PCI_DEV(v,d) - int sub_vendor_id; - int sub_device_id; +#define PCI_DEVICE_SUB(v, d, sv, sd) \ + PCI_DEV(v, d), PCI_SUBDEV(v, d) - int driver_data; - - int match_populated:1; - int match_vendor_id:1; - int match_device_id:1; - int match_sub_vendor_id:1; - int match_sub_device_id:1; -}; - -#define PCI_VDEVICE(v, s) \ - .vendor_id = (v), \ - .device_id = (s), \ - .match_populated = 1, \ - .match_vendor_id = 1, \ - .match_device_id = 1 - -#define PCI_DEVICE_SUB(v, d, dv, ds) \ - .match_populated = 1, \ - .vendor_id = (v), .match_vendor_id = 1, \ - .device_id = (d), .match_device_id = 1, \ - .sub_vendor_id = (dv), .match_sub_vendor_id = 1, \ - .sub_device_id = (ds), .match_sub_device_id = 1 - #define PCI_VENDOR_ID_ATHEROS 0x168c #define PCI_VENDOR_ID_SAMSUNG 0x144d #define PCI_VENDOR_ID_AZWAVE 0x1a3b @@ -130,50 +101,6 @@ struct pci_device_id { #include "if_ath_pci_devlist.h" -/* - * Attempt to find a match for the given device in - * the given device table. - * - * Returns the device structure or NULL if no matching - * PCI device is found. - */ -static const struct pci_device_id * -ath_pci_probe_device(device_t dev, const struct pci_device_id *dev_table, int nentries) -{ - int i; - int vendor_id, device_id; - int sub_vendor_id, sub_device_id; - - vendor_id = pci_get_vendor(dev); - device_id = pci_get_device(dev); - sub_vendor_id = pci_get_subvendor(dev); - sub_device_id = pci_get_subdevice(dev); - - for (i = 0; i < nentries; i++) { - /* Don't match on non-populated (eg empty) entries */ - if (! dev_table[i].match_populated) - continue; - - if (dev_table[i].match_vendor_id && - (dev_table[i].vendor_id != vendor_id)) - continue; - if (dev_table[i].match_device_id && - (dev_table[i].device_id != device_id)) - continue; - if (dev_table[i].match_sub_vendor_id && - (dev_table[i].sub_vendor_id != sub_vendor_id)) - continue; - if (dev_table[i].match_sub_device_id && - (dev_table[i].sub_device_id != sub_device_id)) - continue; - - /* Match */ - return (&dev_table[i]); - } - - return (NULL); -} - #define BS_BAR 0x10 #define PCIR_RETRY_TIMEOUT 0x41 #define PCIR_CFG_PMCSR 0x48 @@ -244,12 +171,12 @@ ath_pci_attach(device_t dev) const struct firmware *fw = NULL; const char *buf; #endif - const struct pci_device_id *pd; + const struct pci_device_table *pd; sc->sc_dev = dev; /* Do this lookup anyway; figure out what to do with it later */ - pd = ath_pci_probe_device(dev, ath_pci_id_table, nitems(ath_pci_id_table)); + pd = PCI_MATCH(dev, ath_pci_id_table); if (pd) sc->sc_pci_devinfo = pd->driver_data; Modified: head/sys/dev/ath/if_ath_pci_devlist.h ============================================================================== --- head/sys/dev/ath/if_ath_pci_devlist.h Sat Jul 7 15:25:11 2018 (r336066) +++ head/sys/dev/ath/if_ath_pci_devlist.h Sat Jul 7 15:25:16 2018 (r336067) @@ -29,7 +29,7 @@ * $FreeBSD$ */ -static const struct pci_device_id ath_pci_id_table[] = { +static const struct pci_device_table ath_pci_id_table[] = { { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x0023) }, /* PCI */ { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x0024) }, /* PCI-E */ { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x0027) }, /* PCI */