summaryrefslogtreecommitdiff
path: root/sys/dev/cardbus
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2005-05-16 01:36:26 +0000
committerBrad Smith <brad@cvs.openbsd.org>2005-05-16 01:36:26 +0000
commit043fdf63d284376eee040ff4b6b189925cc4c02d (patch)
treea34ce84180044e71fd8fc39c06ac65b7c0153f64 /sys/dev/cardbus
parent0415649f3817db0cec17a3c5fa33df846eee2015 (diff)
Use cardbus_matchbyid().
ok millert@ jsg@
Diffstat (limited to 'sys/dev/cardbus')
-rw-r--r--sys/dev/cardbus/if_atw_cardbus.c53
-rw-r--r--sys/dev/cardbus/if_dc_cardbus.c18
-rw-r--r--sys/dev/cardbus/if_fxp_cardbus.c16
-rw-r--r--sys/dev/cardbus/if_ral_cardbus.c16
-rw-r--r--sys/dev/cardbus/if_re_cardbus.c16
-rw-r--r--sys/dev/cardbus/if_rl_cardbus.c38
-rw-r--r--sys/dev/cardbus/if_rtw_cardbus.c37
7 files changed, 47 insertions, 147 deletions
diff --git a/sys/dev/cardbus/if_atw_cardbus.c b/sys/dev/cardbus/if_atw_cardbus.c
index fb2a581871e..c940725e14f 100644
--- a/sys/dev/cardbus/if_atw_cardbus.c
+++ b/sys/dev/cardbus/if_atw_cardbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_atw_cardbus.c,v 1.7 2004/10/07 21:16:59 brad Exp $ */
+/* $OpenBSD: if_atw_cardbus.c,v 1.8 2005/05/16 01:36:25 brad Exp $ */
/* $NetBSD: if_atw_cardbus.c,v 1.9 2004/07/23 07:07:55 dyoung Exp $ */
/*-
@@ -132,47 +132,17 @@ int atw_cardbus_enable(struct atw_softc *);
void atw_cardbus_disable(struct atw_softc *);
void atw_cardbus_power(struct atw_softc *, int);
-const struct atw_cardbus_product *atw_cardbus_lookup
- (const struct cardbus_attach_args *);
-
-const struct atw_cardbus_product {
- u_int32_t acp_vendor; /* PCI vendor ID */
- u_int32_t acp_product; /* PCI product ID */
- const char *acp_product_name;
-} atw_cardbus_products[] = {
- { PCI_VENDOR_ADMTEK, PCI_PRODUCT_ADMTEK_ADM8211,
- "ADMtek ADM8211 802.11 MAC/BBP" },
-
- { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3CRSHPW796,
- "3Com 3CRSHPW796 802.11b" },
-
- { 0, 0, NULL },
+const struct cardbus_matchid atw_cardbus_devices[] = {
+ { PCI_VENDOR_ADMTEK, PCI_PRODUCT_ADMTEK_ADM8211 },
+ { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3CRSHPW796 },
};
-const struct atw_cardbus_product *
-atw_cardbus_lookup(const struct cardbus_attach_args *ca)
-{
- const struct atw_cardbus_product *acp;
-
- for (acp = atw_cardbus_products;
- acp->acp_product_name != NULL;
- acp++) {
- if (PCI_VENDOR(ca->ca_id) == acp->acp_vendor &&
- PCI_PRODUCT(ca->ca_id) == acp->acp_product)
- return (acp);
- }
- return (NULL);
-}
-
int
atw_cardbus_match(struct device *parent, void *match, void *aux)
{
- struct cardbus_attach_args *ca = aux;
-
- if (atw_cardbus_lookup(ca) != NULL)
- return (1);
-
- return (0);
+ return (cardbus_matchbyid((struct cardbus_attach_args *)aux,
+ atw_cardbus_devices,
+ sizeof(atw_cardbus_devices)/sizeof(atw_cardbus_devices[0])));
}
void
@@ -182,19 +152,12 @@ atw_cardbus_attach(struct device *parent, struct device *self, void *aux)
struct atw_softc *sc = &csc->sc_atw;
struct cardbus_attach_args *ca = aux;
cardbus_devfunc_t ct = ca->ca_ct;
- const struct atw_cardbus_product *acp;
bus_addr_t adr;
sc->sc_dmat = ca->ca_dmat;
csc->sc_ct = ct;
csc->sc_tag = ca->ca_tag;
- acp = atw_cardbus_lookup(ca);
- if (acp == NULL) {
- printf("\n");
- panic("atw_cardbus_attach: impossible");
- }
-
/*
* Power management hooks.
*/
@@ -259,7 +222,7 @@ atw_cardbus_attach(struct device *parent, struct device *self, void *aux)
/* Remember which interrupt line. */
csc->sc_intrline = ca->ca_intrline;
- printf(": %s, revision %d.%d: irq %d\n", acp->acp_product_name,
+ printf(": revision %d.%d: irq %d\n",
(sc->sc_rev >> 4) & 0xf, sc->sc_rev & 0xf, csc->sc_intrline);
#if 0
/*
diff --git a/sys/dev/cardbus/if_dc_cardbus.c b/sys/dev/cardbus/if_dc_cardbus.c
index 56c94ce76cd..d5dd0fc770f 100644
--- a/sys/dev/cardbus/if_dc_cardbus.c
+++ b/sys/dev/cardbus/if_dc_cardbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_dc_cardbus.c,v 1.18 2005/01/16 20:47:44 brad Exp $ */
+/* $OpenBSD: if_dc_cardbus.c,v 1.19 2005/05/16 01:36:25 brad Exp $ */
#include <sys/param.h>
#include <sys/systm.h>
@@ -61,7 +61,7 @@ struct cfattach dc_cardbus_ca = {
dc_cardbus_detach
};
-struct dc_type dc_cardbus_devs[] = {
+const struct cardbus_matchid dc_cardbus_devices[] = {
{ PCI_VENDOR_DEC, PCI_PRODUCT_DEC_21142 },
{ PCI_VENDOR_XIRCOM, PCI_PRODUCT_XIRCOM_X3201_3_21143 },
{ PCI_VENDOR_ADMTEK, PCI_PRODUCT_ADMTEK_AN985 },
@@ -71,7 +71,6 @@ struct dc_type dc_cardbus_devs[] = {
{ PCI_VENDOR_LINKSYS, PCI_PRODUCT_LINKSYS_PCM200 },
{ PCI_VENDOR_HAWKING, PCI_PRODUCT_HAWKING_PN672TX },
{ PCI_VENDOR_MICROSOFT, PCI_PRODUCT_MICROSOFT_MN120 },
- { 0 }
};
int
@@ -79,16 +78,9 @@ dc_cardbus_match(parent, match, aux)
struct device *parent;
void *match, *aux;
{
- struct cardbus_attach_args *ca = aux;
- struct dc_type *t;
-
- for (t = dc_cardbus_devs; t->dc_vid != 0; t++) {
- if ((PCI_VENDOR(ca->ca_id) == t->dc_vid) &&
- (PCI_PRODUCT(ca->ca_id) == t->dc_did))
- return (1);
- }
-
- return (0);
+ return (cardbus_matchbyid((struct cardbus_attach_args *)aux,
+ dc_cardbus_devices,
+ sizeof(dc_cardbus_devices)/sizeof(dc_cardbus_devices[0])));
}
void
diff --git a/sys/dev/cardbus/if_fxp_cardbus.c b/sys/dev/cardbus/if_fxp_cardbus.c
index e32f3be3c58..aa508bbf0a2 100644
--- a/sys/dev/cardbus/if_fxp_cardbus.c
+++ b/sys/dev/cardbus/if_fxp_cardbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_fxp_cardbus.c,v 1.10 2005/01/14 01:06:16 pvalchev Exp $ */
+/* $OpenBSD: if_fxp_cardbus.c,v 1.11 2005/05/16 01:36:25 brad Exp $ */
/* $NetBSD: if_fxp_cardbus.c,v 1.12 2000/05/08 18:23:36 thorpej Exp $ */
/*
@@ -104,6 +104,10 @@ struct cfattach fxp_cardbus_ca = {
fxp_cardbus_detach
};
+const struct cardbus_matchid fxp_cardbus_devices[] = {
+ { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82557 },
+};
+
#ifdef CBB_DEBUG
#define DPRINTF(X) printf X
#else
@@ -116,13 +120,9 @@ fxp_cardbus_match(parent, match, aux)
void *match;
void *aux;
{
- struct cardbus_attach_args *ca = aux;
-
- if (CARDBUS_VENDOR(ca->ca_id) == PCI_VENDOR_INTEL &&
- CARDBUS_PRODUCT(ca->ca_id) == PCI_PRODUCT_INTEL_82557)
- return (1);
-
- return (0);
+ return (cardbus_matchbyid((struct cardbus_attach_args *)aux,
+ fxp_cardbus_devices,
+ sizeof(fxp_cardbus_devices)/sizeof(fxp_cardbus_devices[0])));
}
void
diff --git a/sys/dev/cardbus/if_ral_cardbus.c b/sys/dev/cardbus/if_ral_cardbus.c
index 5b62a2587c1..d84327efa8d 100644
--- a/sys/dev/cardbus/if_ral_cardbus.c
+++ b/sys/dev/cardbus/if_ral_cardbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ral_cardbus.c,v 1.4 2005/02/22 10:40:46 damien Exp $ */
+/* $OpenBSD: if_ral_cardbus.c,v 1.5 2005/05/16 01:36:25 brad Exp $ */
/*-
* Copyright (c) 2005
@@ -76,6 +76,10 @@ struct cfattach ral_cardbus_ca = {
ral_cardbus_attach, ral_cardbus_detach
};
+const struct cardbus_matchid ral_cardbus_devices[] = {
+ { PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT2560 },
+};
+
int ral_cardbus_enable(struct ral_softc *);
void ral_cardbus_disable(struct ral_softc *);
void ral_cardbus_power(struct ral_softc *, int);
@@ -84,13 +88,9 @@ void ral_cardbus_setup(struct ral_cardbus_softc *);
int
ral_cardbus_match(struct device *parent, void *match, void *aux)
{
- struct cardbus_attach_args *ca = aux;
-
- if (CARDBUS_VENDOR(ca->ca_id) == PCI_VENDOR_RALINK &&
- CARDBUS_PRODUCT(ca->ca_id) == PCI_PRODUCT_RALINK_RT2560)
- return 1;
-
- return 0;
+ return (cardbus_matchbyid((struct cardbus_attach_args *)aux,
+ ral_cardbus_devices,
+ sizeof(ral_cardbus_devices)/sizeof(ral_cardbus_devices[0])));
}
void
diff --git a/sys/dev/cardbus/if_re_cardbus.c b/sys/dev/cardbus/if_re_cardbus.c
index ef7a387e10e..424d4e2bd99 100644
--- a/sys/dev/cardbus/if_re_cardbus.c
+++ b/sys/dev/cardbus/if_re_cardbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_re_cardbus.c,v 1.1 2005/01/14 02:52:06 pvalchev Exp $ */
+/* $OpenBSD: if_re_cardbus.c,v 1.2 2005/05/16 01:36:25 brad Exp $ */
/*
* Copyright (c) 2005 Peter Valchev <pvalchev@openbsd.org>
@@ -87,6 +87,10 @@ struct cfattach re_cardbus_ca = {
re_cardbus_detach
};
+const struct cardbus_matchid re_cardbus_devices[] = {
+ { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8169 },
+};
+
/*
* Probe for a RealTek 8169/8110 chip. Check the PCI vendor and device
* IDs against our list and return a device name if we find a match.
@@ -94,13 +98,9 @@ struct cfattach re_cardbus_ca = {
int
re_cardbus_probe(struct device *parent, void *match, void *aux)
{
- struct cardbus_attach_args *ca = aux;
-
- if (CARDBUS_VENDOR(ca->ca_id) == PCI_VENDOR_REALTEK &&
- CARDBUS_PRODUCT(ca->ca_id) == PCI_PRODUCT_REALTEK_RT8169)
- return 1;
-
- return 0;
+ return (cardbus_matchbyid((struct cardbus_attach_args *)aux,
+ re_cardbus_devices,
+ sizeof(re_cardbus_devices)/sizeof(re_cardbus_devices[0])));
}
/*
diff --git a/sys/dev/cardbus/if_rl_cardbus.c b/sys/dev/cardbus/if_rl_cardbus.c
index 9187f38c506..50aee1339cb 100644
--- a/sys/dev/cardbus/if_rl_cardbus.c
+++ b/sys/dev/cardbus/if_rl_cardbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_rl_cardbus.c,v 1.8 2004/10/07 21:16:59 brad Exp $ */
+/* $OpenBSD: if_rl_cardbus.c,v 1.9 2005/05/16 01:36:25 brad Exp $ */
/* $NetBSD: if_rl_cardbus.c,v 1.3.8.3 2001/11/14 19:14:02 nathanw Exp $ */
/*
@@ -93,7 +93,7 @@
/*
* Various supported device vendors/types and their names.
*/
-static const struct rl_type rl_cardbus_devs[] = {
+const struct cardbus_matchid rl_cardbus_devices[] = {
{ PCI_VENDOR_ACCTON, PCI_PRODUCT_ACCTON_5030 },
{ PCI_VENDOR_ABOCOM, PCI_PRODUCT_ABOCOM_TE100 },
{ PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8138 },
@@ -103,7 +103,6 @@ static const struct rl_type rl_cardbus_devs[] = {
{ PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DFE690TXD },
{ PCI_VENDOR_PLANEX, PCI_PRODUCT_PLANEX_FNW_3603_TX },
{ PCI_VENDOR_PLANEX, PCI_PRODUCT_PLANEX_FNW_3800_TX },
- { 0, 0 }
};
struct rl_cardbus_softc {
@@ -131,35 +130,15 @@ struct cfattach rl_cardbus_ca = {
rl_cardbus_detach
};
-const struct rl_type *rl_cardbus_lookup (const struct cardbus_attach_args *);
-
-const struct rl_type *
-rl_cardbus_lookup(ca)
- const struct cardbus_attach_args *ca;
-{
- const struct rl_type *t;
-
- for (t = rl_cardbus_devs; t->rl_vid != 0; t++){
- if (CARDBUS_VENDOR(ca->ca_id) == t->rl_vid &&
- CARDBUS_PRODUCT(ca->ca_id) == t->rl_did) {
- return (t);
- }
- }
- return (NULL);
-}
-
int
rl_cardbus_match(parent, match, aux)
struct device *parent;
void *match;
void *aux;
{
- struct cardbus_attach_args *ca = aux;
-
- if (rl_cardbus_lookup(ca) != NULL)
- return (1);
-
- return (0);
+ return (cardbus_matchbyid((struct cardbus_attach_args *)aux,
+ rl_cardbus_devices,
+ sizeof(rl_cardbus_devices)/sizeof(rl_cardbus_devices[0])));
}
@@ -176,7 +155,6 @@ rl_cardbus_attach(parent, self, aux)
cardbus_chipset_tag_t cc = psc->sc_cc;
cardbus_function_tag_t cf = psc->sc_cf;
cardbus_devfunc_t ct = ca->ca_ct;
- const struct rl_type *t;
bus_addr_t adr;
sc->sc_dmat = ca->ca_dmat;
@@ -184,12 +162,6 @@ rl_cardbus_attach(parent, self, aux)
csc->sc_tag = ca->ca_tag;
csc->sc_intrline = ca->ca_intrline;
- t = rl_cardbus_lookup(ca);
- if (t == NULL) {
- printf("\n");
- panic("rl_cardbus_attach: impossible");
- }
-
/*
* Map control/status registers.
*/
diff --git a/sys/dev/cardbus/if_rtw_cardbus.c b/sys/dev/cardbus/if_rtw_cardbus.c
index 92ed6c4baf4..9aef539f7d3 100644
--- a/sys/dev/cardbus/if_rtw_cardbus.c
+++ b/sys/dev/cardbus/if_rtw_cardbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_rtw_cardbus.c,v 1.4 2005/02/10 12:14:53 jsg Exp $ */
+/* $OpenBSD: if_rtw_cardbus.c,v 1.5 2005/05/16 01:36:25 brad Exp $ */
/* $NetBSD: if_rtw_cardbus.c,v 1.4 2004/12/20 21:05:34 dyoung Exp $ */
/*-
@@ -166,38 +166,18 @@ int rtw_cardbus_enable(struct rtw_softc *);
void rtw_cardbus_disable(struct rtw_softc *);
void rtw_cardbus_power(struct rtw_softc *, int);
-const struct rtw_cardbus_product *rtw_cardbus_lookup(
- const struct cardbus_attach_args *);
-
-const struct rtw_cardbus_product {
- u_int32_t rcp_vendor; /* PCI vendor ID */
- u_int32_t rcp_product; /* PCI product ID */
-} rtw_cardbus_products[] = {
+const struct cardbus_matchid rtw_cardbus_devices[] = {
{ PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8180 },
{ PCI_VENDOR_BELKIN2, PCI_PRODUCT_BELKIN2_F5D6020V3 },
{ PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DWL610 },
- { 0, 0 }
};
-const struct rtw_cardbus_product *
-rtw_cardbus_lookup(const struct cardbus_attach_args *ca)
-{
- const struct rtw_cardbus_product *rcp;
-
- for (rcp = rtw_cardbus_products; rcp->rcp_product != 0; rcp++) {
- if (PCI_VENDOR(ca->ca_id) == rcp->rcp_vendor &&
- PCI_PRODUCT(ca->ca_id) == rcp->rcp_product)
- return (rcp);
- }
- return (NULL);
-}
-
int
rtw_cardbus_match(struct device *parent, void *match, void *aux)
{
- struct cardbus_attach_args *ca = aux;
-
- return (rtw_cardbus_lookup(ca) != NULL);
+ return (cardbus_matchbyid((struct cardbus_attach_args *)aux,
+ rtw_cardbus_devices,
+ sizeof(rtw_cardbus_devices)/sizeof(rtw_cardbus_devices[0])));
}
void
@@ -228,7 +208,6 @@ rtw_cardbus_attach(struct device *parent, struct device *self, void *aux)
struct rtw_regs *regs = &sc->sc_regs;
struct cardbus_attach_args *ca = aux;
cardbus_devfunc_t ct = ca->ca_ct;
- const struct rtw_cardbus_product *rcp;
bus_addr_t adr;
int rev;
@@ -236,12 +215,6 @@ rtw_cardbus_attach(struct device *parent, struct device *self, void *aux)
csc->sc_ct = ct;
csc->sc_tag = ca->ca_tag;
- rcp = rtw_cardbus_lookup(ca);
- if (rcp == NULL) {
- printf("\n");
- panic("rtw_cardbus_attach: impossible");
- }
-
/*
* Power management hooks.
*/