Page MenuHomeFreeBSD

D15999.id44395.diff
No OneTemporary

D15999.id44395.diff

Index: sys/dev/ath/if_ath_pci.c
===================================================================
--- sys/dev/ath/if_ath_pci.c
+++ sys/dev/ath/if_ath_pci.c
@@ -82,40 +82,12 @@
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;
-
- int sub_vendor_id;
- int sub_device_id;
-
- int driver_data;
+#define PCI_VDEVICE(v, s) \
+ PCI_VENDOR(v), PCI_DEVICE(s)
- 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, dv, ds) \
+ PCI_VENDOR(v), PCI_DEVICE(d), \
+ PCI_SUBVENDOR(dv), PCI_SUBDEVICE(ds)
#define PCI_VENDOR_ID_ATHEROS 0x168c
#define PCI_VENDOR_ID_SAMSUNG 0x144d
@@ -130,50 +102,6 @@
#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 +172,12 @@
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;
Index: sys/dev/ath/if_ath_pci_devlist.h
===================================================================
--- sys/dev/ath/if_ath_pci_devlist.h
+++ sys/dev/ath/if_ath_pci_devlist.h
@@ -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 */
Index: sys/dev/pci/pci.c
===================================================================
--- sys/dev/pci/pci.c
+++ sys/dev/pci/pci.c
@@ -6244,3 +6244,44 @@
pci_printf(&dinfo->cfg, "Transactions pending after FLR!\n");
return (true);
}
+
+const void *
+pci_match_device(device_t child, const void *table, size_t elt, size_t nelt)
+{
+ const char *ptr, *end;
+ const struct pci_device_table *id;
+ bool match;
+ uint16_t vendor, device, subvendor, subdevice, class, subclass, revid;
+
+ ptr = (const char *) table;
+ end = ptr + elt * nelt;
+ vendor = pci_get_vendor(child);
+ device = pci_get_device(child);
+ subvendor = pci_get_subvendor(child);
+ subdevice = pci_get_subdevice(child);
+ class = pci_get_class(child);
+ subclass = pci_get_subclass(child);
+ revid = pci_get_revid(child);
+ while (ptr < end) {
+ id = (const struct pci_device_id *)ptr;
+ match = true;
+ if (id->match_flag_vendor)
+ match &= vendor == id->vendor;
+ if (id->match_flag_device)
+ match &= device == id->device;
+ if (id->match_flag_subvendor)
+ match &= subvendor == id->subvendor;
+ if (id->match_flag_subdevice)
+ match &= subdevice == id->subdevice;
+ if (id->match_flag_class)
+ match &= class == id->class_id;
+ if (id->match_flag_subclass)
+ match &= subclass == id->subclass;
+ if (id->match_flag_revid)
+ match &= revid == id->revid;
+ if (match)
+ return (id);
+ ptr += elt;
+ }
+ return (NULL);
+}
Index: sys/dev/pci/pcivar.h
===================================================================
--- sys/dev/pci/pcivar.h
+++ sys/dev/pci/pcivar.h
@@ -259,6 +259,64 @@
extern uint32_t pci_numdevs;
+struct pci_device_table {
+#if BYTE_ORDER == LITTLE_ENDIAN
+ uint16_t
+ match_flag_vendor:1,
+ match_flag_device:1,
+ match_flag_subvendor:1,
+ match_flag_subdevice:1,
+ match_flag_class:1,
+ match_flag_subclass:1,
+ match_flag_revid:1,
+ match_flag_unused:9;
+#else
+ uint16_t
+ match_flag_unused:9,
+ match_flag_revid:1,
+ match_flag_subclass:1,
+ match_flag_class:1,
+ match_flag_subdevice:1,
+ match_flag_subvendor:1,
+ match_flag_device:1,
+ match_flag_vendor:1;
+#endif
+ uint16_t vendor;
+ uint16_t device;
+ uint16_t subvendor;
+ uint16_t subdevice;
+ uint16_t class_id;
+ uint16_t subclass;
+ uint16_t revid;
+ uint16_t unused;
+ uintptr_t driver_data;
+};
+
+#define PCI_VENDOR(x) \
+ .match_flag_vendor = 1, .vendor = (x)
+#define PCI_DEVICE(x) \
+ .match_flag_device = 1, .device = (x)
+#define PCI_SUBVENDOR(x) \
+ .match_flag_subvendor = 1, .subvendor = (x)
+#define PCI_SUBDEVICE(x) \
+ .match_flag_subdevice = 1, .subdevice = (x)
+#define PCI_CLASS(x) \
+ .match_flag_class = 1, .class_id = (x)
+#define PCI_SUBCLASS(x) \
+ .match_flag_subclass = 1, .subclass = (x)
+#define PCI_REVID(x) \
+ .match_flag_revid = 1, .revid = (x)
+#define PCI_PNP_STR \
+ "M16:mask;U16:vendor;U16:device;U16:subvendor;U16:subdevice;" \
+ "U16:class;U16:subclass;U16:revid;"
+#define PCI_PNP_INFO(table) \
+ MODULE_PNP_INFO(PCI_PNP_STR, pci, table, table, sizeof(table[0]), \
+ sizeof(table) / sizeof(table[0]))
+
+const void *pci_match_device(device_t child, const void *table, size_t elt, size_t nelt);
+#define PCI_MATCH(child, table) \
+ pci_match_device(child, (table), sizeof((table)[0]), nitems(table));
+
/* Only if the prerequisites are present */
#if defined(_SYS_BUS_H_) && defined(_SYS_PCIIO_H_)
struct pci_devinfo {
@@ -416,7 +474,7 @@
static __inline int
pci_is_vga_ioport_range(rman_res_t start, rman_res_t end)
{
-
+
return (((start >= 0x3b0 && end <= 0x3bb) ||
(start >= 0x3c0 && end <= 0x3df)) ? 1 : 0);
}

File Metadata

Mime Type
text/plain
Expires
Fri, Feb 13, 2:28 AM (16 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28672744
Default Alt Text
D15999.id44395.diff (7 KB)

Event Timeline