Switch to using new PCI_MATCH stuff.

This commit is contained in:
Warner Losh 2018-07-07 15:25:16 +00:00
parent 971b5f7632
commit 4d711ae269
2 changed files with 7 additions and 80 deletions

View File

@ -82,40 +82,11 @@ 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;
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_DEVICE_SUB(v, d, sv, sd) \
PCI_DEV(v, d), PCI_SUBDEV(v, d)
#define PCI_VENDOR_ID_ATHEROS 0x168c
#define PCI_VENDOR_ID_SAMSUNG 0x144d
@ -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;

View File

@ -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 */