summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2005-05-10 02:37:47 +0000
committerBrad Smith <brad@cvs.openbsd.org>2005-05-10 02:37:47 +0000
commitc325222654369a01f0e0de3076b7d026cb807579 (patch)
treef095365c537fd7bea67604fe791b1db323ed9742
parente49d5d73a0297cd1027a4c567c618f128d5cd06b (diff)
use pci_matchbyid().
-rw-r--r--sys/dev/pci/if_epic_pci.c42
1 files changed, 6 insertions, 36 deletions
diff --git a/sys/dev/pci/if_epic_pci.c b/sys/dev/pci/if_epic_pci.c
index 1aad3554170..6ae9bf29ebc 100644
--- a/sys/dev/pci/if_epic_pci.c
+++ b/sys/dev/pci/if_epic_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_epic_pci.c,v 1.1 2005/05/10 01:16:32 brad Exp $ */
+/* $OpenBSD: if_epic_pci.c,v 1.2 2005/05/10 02:37:46 brad Exp $ */
/* $NetBSD: if_epic_pci.c,v 1.28 2005/02/27 00:27:32 perry Exp $ */
/*-
@@ -104,30 +104,11 @@ struct cfattach epic_pci_ca = {
sizeof(struct epic_pci_softc), epic_pci_match, epic_pci_attach
};
-static const struct epic_pci_product {
- u_int32_t epp_prodid; /* PCI product ID */
- const char *epp_name; /* device name */
-} epic_pci_products[] = {
- { PCI_PRODUCT_SMC_83C170, "SMC 83c170 Fast Ethernet" },
- { PCI_PRODUCT_SMC_83C175, "SMC 83c175 Fast Ethernet" },
- { 0, NULL },
+const struct pci_matchid epic_pci_devices[] = {
+ { PCI_VENDOR_SMC, PCI_PRODUCT_SMC_83C170 },
+ { PCI_VENDOR_SMC, PCI_PRODUCT_SMC_83C175 },
};
-static const struct epic_pci_product *
-epic_pci_lookup(const struct pci_attach_args *pa)
-{
- const struct epic_pci_product *epp;
-
- if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_SMC)
- return (NULL);
-
- for (epp = epic_pci_products; epp->epp_name != NULL; epp++)
- if (PCI_PRODUCT(pa->pa_id) == epp->epp_prodid)
- return (epp);
-
- return (NULL);
-}
-
static const struct epic_pci_subsys_info {
pcireg_t subsysid;
int flags;
@@ -161,12 +142,8 @@ epic_pci_subsys_lookup(const struct pci_attach_args *pa)
static int
epic_pci_match(struct device *parent, void *match, void *aux)
{
- struct pci_attach_args *pa = aux;
-
- if (epic_pci_lookup(pa) != NULL)
- return (1);
-
- return (0);
+ return (pci_matchbyid((struct pci_attach_args *)aux, epic_pci_devices,
+ sizeof(epic_pci_devices)/sizeof(epic_pci_devices[0])));
}
static void
@@ -178,19 +155,12 @@ epic_pci_attach(struct device *parent, struct device *self, void *aux)
pci_chipset_tag_t pc = pa->pa_pc;
pci_intr_handle_t ih;
const char *intrstr = NULL;
- const struct epic_pci_product *epp;
const struct epic_pci_subsys_info *esp;
bus_space_tag_t iot, memt;
bus_space_handle_t ioh, memh;
pcireg_t reg;
int pmreg, ioh_valid, memh_valid;
- epp = epic_pci_lookup(pa);
- if (epp == NULL) {
- printf("\n");
- panic(": epic_pci_attach: impossible");
- }
-
if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, &pmreg, 0)) {
reg = pci_conf_read(pc, pa->pa_tag, pmreg + PCI_PMCSR);
switch (reg & PCI_PMCSR_STATE_MASK) {