replace the *_lookup table entry match/lookup functions in all of
these drivers with a single common function (which supports tables of variable-sized structures). Things are mostly as they were before: tables are terminated by entry with NULL name, etc. There's also the ability to call a driver-specific match function which can be used to augment the table lookup.
This commit is contained in:
parent
dd84ecc7ac
commit
942a54e0c1
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: aic_pcmcia.c,v 1.14 1999/11/18 14:20:11 enami Exp $ */
|
||||
/* $NetBSD: aic_pcmcia.c,v 1.15 2000/02/04 01:27:12 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Marc Horowitz. All rights reserved.
|
||||
@ -71,40 +71,19 @@ struct cfattach aic_pcmcia_ca = {
|
||||
|
||||
int aic_pcmcia_enable __P((void *, int));
|
||||
|
||||
struct aic_pcmcia_product {
|
||||
u_int32_t app_vendor; /* PCMCIA vendor ID */
|
||||
u_int32_t app_product; /* PCMCIA product ID */
|
||||
int app_expfunc; /* expected function number */
|
||||
const char *app_name; /* device name */
|
||||
} aic_pcmcia_products[] = {
|
||||
{ PCMCIA_VENDOR_ADAPTEC, PCMCIA_PRODUCT_ADAPTEC_APA1460,
|
||||
0, PCMCIA_STR_ADAPTEC_APA1460 },
|
||||
{ PCMCIA_VENDOR_ADAPTEC, PCMCIA_PRODUCT_ADAPTEC_APA1460A,
|
||||
0, PCMCIA_STR_ADAPTEC_APA1460A },
|
||||
{ PCMCIA_VENDOR_NEWMEDIA, PCMCIA_PRODUCT_NEWMEDIA_BUSTOASTER,
|
||||
0, PCMCIA_STR_NEWMEDIA_BUSTOASTER },
|
||||
const struct pcmcia_product aic_pcmcia_products[] = {
|
||||
{ PCMCIA_STR_ADAPTEC_APA1460, PCMCIA_VENDOR_ADAPTEC,
|
||||
PCMCIA_PRODUCT_ADAPTEC_APA1460, 0 },
|
||||
|
||||
{ 0, 0,
|
||||
0, NULL },
|
||||
{ PCMCIA_STR_ADAPTEC_APA1460A, PCMCIA_VENDOR_ADAPTEC,
|
||||
PCMCIA_PRODUCT_ADAPTEC_APA1460A, 0 },
|
||||
|
||||
{ PCMCIA_STR_NEWMEDIA_BUSTOASTER, PCMCIA_VENDOR_NEWMEDIA,
|
||||
PCMCIA_PRODUCT_NEWMEDIA_BUSTOASTER, 0 },
|
||||
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
struct aic_pcmcia_product *aic_pcmcia_lookup __P((struct pcmcia_attach_args *));
|
||||
|
||||
struct aic_pcmcia_product *
|
||||
aic_pcmcia_lookup(pa)
|
||||
struct pcmcia_attach_args *pa;
|
||||
{
|
||||
struct aic_pcmcia_product *app;
|
||||
|
||||
for (app = aic_pcmcia_products; app->app_name != NULL; app++) {
|
||||
if (pa->manufacturer == app->app_vendor &&
|
||||
pa->product == app->app_product &&
|
||||
pa->pf->number == app->app_expfunc)
|
||||
return (app);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int
|
||||
aic_pcmcia_match(parent, match, aux)
|
||||
struct device *parent;
|
||||
@ -113,7 +92,8 @@ aic_pcmcia_match(parent, match, aux)
|
||||
{
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
|
||||
if (aic_pcmcia_lookup(pa) != NULL)
|
||||
if (pcmcia_product_lookup(pa, aic_pcmcia_products,
|
||||
sizeof aic_pcmcia_products[0], NULL) != NULL)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
@ -128,7 +108,7 @@ aic_pcmcia_attach(parent, self, aux)
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
struct pcmcia_config_entry *cfe;
|
||||
struct pcmcia_function *pf = pa->pf;
|
||||
struct aic_pcmcia_product *app;
|
||||
const struct pcmcia_product *pp;
|
||||
|
||||
psc->sc_pf = pf;
|
||||
|
||||
@ -179,13 +159,14 @@ aic_pcmcia_attach(parent, self, aux)
|
||||
return;
|
||||
}
|
||||
|
||||
app = aic_pcmcia_lookup(pa);
|
||||
if (app == NULL) {
|
||||
pp = pcmcia_product_lookup(pa, aic_pcmcia_products,
|
||||
sizeof aic_pcmcia_products[0], NULL);
|
||||
if (pp == NULL) {
|
||||
printf("\n");
|
||||
panic("aic_pcmcia_attach: impossible");
|
||||
}
|
||||
|
||||
printf(": %s\n", app->app_name);
|
||||
printf(": %s\n", pp->pp_name);
|
||||
|
||||
/* We can enable and disable the controller. */
|
||||
sc->sc_adapter.scsipi_enable = aic_pcmcia_enable;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* $NetBSD: if_ep_pcmcia.c,v 1.28 2000/02/02 08:41:01 augustss Exp $ */
|
||||
/* $NetBSD: if_ep_pcmcia.c,v 1.29 2000/02/04 01:27:12 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
@ -141,57 +141,38 @@ struct cfattach ep_pcmcia_ca = {
|
||||
ep_pcmcia_detach, ep_activate
|
||||
};
|
||||
|
||||
struct ep_pcmcia_product {
|
||||
u_int32_t epp_product; /* PCMCIA product ID */
|
||||
const struct ep_pcmcia_product {
|
||||
struct pcmcia_product epp_product;
|
||||
u_short epp_chipset; /* 3Com chipset used */
|
||||
int epp_flags; /* initial softc flags */
|
||||
int epp_expfunc; /* expected function */
|
||||
const char *epp_name; /* device name */
|
||||
} ep_pcmcia_products[] = {
|
||||
{ PCMCIA_PRODUCT_3COM_3C562, ELINK_CHIPSET_3C509,
|
||||
0, 0,
|
||||
PCMCIA_STR_3COM_3C562 },
|
||||
{ PCMCIA_PRODUCT_3COM_3C589, ELINK_CHIPSET_3C509,
|
||||
0, 0,
|
||||
PCMCIA_STR_3COM_3C589 },
|
||||
{ { PCMCIA_STR_3COM_3C562, PCMCIA_VENDOR_3COM,
|
||||
PCMCIA_PRODUCT_3COM_3C562, 0 },
|
||||
ELINK_CHIPSET_3C509, 0 },
|
||||
|
||||
{ PCMCIA_PRODUCT_3COM_3CXEM556, ELINK_CHIPSET_3C509,
|
||||
0, 0,
|
||||
PCMCIA_STR_3COM_3CXEM556 },
|
||||
{ { PCMCIA_STR_3COM_3C589, PCMCIA_VENDOR_3COM,
|
||||
PCMCIA_PRODUCT_3COM_3C589, 0 },
|
||||
ELINK_CHIPSET_3C509, 0 },
|
||||
|
||||
{ PCMCIA_PRODUCT_3COM_3CXEM556INT, ELINK_CHIPSET_3C509,
|
||||
0, 0,
|
||||
PCMCIA_STR_3COM_3CXEM556INT },
|
||||
{ { PCMCIA_STR_3COM_3CXEM556, PCMCIA_VENDOR_3COM,
|
||||
PCMCIA_PRODUCT_3COM_3CXEM556, 0 },
|
||||
ELINK_CHIPSET_3C509, 0 },
|
||||
|
||||
{ PCMCIA_PRODUCT_3COM_3C574, ELINK_CHIPSET_ROADRUNNER,
|
||||
ELINK_FLAGS_MII, 0,
|
||||
PCMCIA_STR_3COM_3C574 },
|
||||
{ { PCMCIA_STR_3COM_3CXEM556INT, PCMCIA_VENDOR_3COM,
|
||||
PCMCIA_PRODUCT_3COM_3CXEM556INT, 0 },
|
||||
ELINK_CHIPSET_3C509, 0 },
|
||||
|
||||
{ PCMCIA_PRODUCT_3COM_3CCFEM556BI, ELINK_CHIPSET_ROADRUNNER,
|
||||
ELINK_FLAGS_MII, 0,
|
||||
PCMCIA_STR_3COM_3CCFEM556BI },
|
||||
{ { PCMCIA_STR_3COM_3C574, PCMCIA_VENDOR_3COM,
|
||||
PCMCIA_PRODUCT_3COM_3C574, 0 },
|
||||
ELINK_CHIPSET_ROADRUNNER, ELINK_FLAGS_MII },
|
||||
|
||||
{ 0, 0,
|
||||
0, 0,
|
||||
NULL },
|
||||
{ { PCMCIA_STR_3COM_3CCFEM556BI, PCMCIA_VENDOR_3COM,
|
||||
PCMCIA_PRODUCT_3COM_3CCFEM556BI, 0 },
|
||||
ELINK_CHIPSET_ROADRUNNER, ELINK_FLAGS_MII },
|
||||
|
||||
{ { NULL } }
|
||||
};
|
||||
|
||||
struct ep_pcmcia_product *ep_pcmcia_lookup __P((struct pcmcia_attach_args *));
|
||||
|
||||
struct ep_pcmcia_product *
|
||||
ep_pcmcia_lookup(pa)
|
||||
struct pcmcia_attach_args *pa;
|
||||
{
|
||||
struct ep_pcmcia_product *epp;
|
||||
|
||||
for (epp = ep_pcmcia_products; epp->epp_name != NULL; epp++)
|
||||
if (pa->product == epp->epp_product &&
|
||||
pa->pf->number == epp->epp_expfunc)
|
||||
return (epp);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int
|
||||
ep_pcmcia_match(parent, match, aux)
|
||||
struct device *parent;
|
||||
@ -200,10 +181,9 @@ ep_pcmcia_match(parent, match, aux)
|
||||
{
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
|
||||
if (pa->manufacturer != PCMCIA_VENDOR_3COM)
|
||||
return (0);
|
||||
|
||||
if (ep_pcmcia_lookup(pa) != NULL)
|
||||
if (pcmcia_product_lookup(pa,
|
||||
(const struct pcmcia_product *)ep_pcmcia_products,
|
||||
sizeof ep_pcmcia_products[0], NULL) != NULL)
|
||||
return (1);
|
||||
|
||||
return (0);
|
||||
@ -286,7 +266,7 @@ ep_pcmcia_attach(parent, self, aux)
|
||||
struct ep_softc *sc = &psc->sc_ep;
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
struct pcmcia_config_entry *cfe;
|
||||
struct ep_pcmcia_product *epp;
|
||||
const struct ep_pcmcia_product *epp;
|
||||
u_int8_t myla[ETHER_ADDR_LEN];
|
||||
u_int8_t *enaddr = NULL;
|
||||
int i;
|
||||
@ -361,11 +341,13 @@ ep_pcmcia_attach(parent, self, aux)
|
||||
break;
|
||||
}
|
||||
|
||||
epp = ep_pcmcia_lookup(pa);
|
||||
epp = (const struct ep_pcmcia_product *)pcmcia_product_lookup(pa,
|
||||
(const struct pcmcia_product *)ep_pcmcia_products,
|
||||
sizeof ep_pcmcia_products[0], NULL);
|
||||
if (epp == NULL)
|
||||
panic("ep_pcmcia_attach: impossible");
|
||||
|
||||
printf(": %s\n", epp->epp_name);
|
||||
printf(": %s\n", epp->epp_product.pp_name);
|
||||
|
||||
sc->bustype = ELINK_BUS_PCMCIA;
|
||||
sc->ep_flags = epp->epp_flags;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* $NetBSD: if_mbe_pcmcia.c,v 1.12 2000/02/02 09:34:51 enami Exp $ */
|
||||
/* $NetBSD: if_mbe_pcmcia.c,v 1.13 2000/02/04 01:27:13 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
@ -88,61 +88,38 @@ struct mbe_pcmcia_get_enaddr_args {
|
||||
};
|
||||
int mbe_pcmcia_get_enaddr __P((struct pcmcia_tuple *, void *));
|
||||
|
||||
struct mbe_pcmcia_product {
|
||||
u_int32_t mpp_vendor; /* vendor ID */
|
||||
u_int32_t mpp_product; /* product ID */
|
||||
int mpp_expfunc; /* exptected function */
|
||||
const struct mbe_pcmcia_product {
|
||||
struct pcmcia_product mpp_product;
|
||||
u_int32_t mpp_ioalign; /* required alignment */
|
||||
const char *mpp_name; /* product name */
|
||||
} mbe_pcmcia_products[] = {
|
||||
{ PCMCIA_VENDOR_TDK, PCMCIA_PRODUCT_TDK_LAK_CD021BX,
|
||||
0, 0,
|
||||
PCMCIA_STR_TDK_LAK_CD021BX },
|
||||
{ { PCMCIA_STR_TDK_LAK_CD021BX, PCMCIA_VENDOR_TDK,
|
||||
PCMCIA_PRODUCT_TDK_LAK_CD021BX, 0 },
|
||||
0 },
|
||||
|
||||
{ PCMCIA_VENDOR_TDK, PCMCIA_PRODUCT_TDK_LAK_CF010,
|
||||
0, 0,
|
||||
PCMCIA_STR_TDK_LAK_CF010},
|
||||
{ { PCMCIA_STR_TDK_LAK_CF010, PCMCIA_VENDOR_TDK,
|
||||
PCMCIA_PRODUCT_TDK_LAK_CF010, 0 },
|
||||
0 },
|
||||
#if 0 /* XXX 86960-based? */
|
||||
{ PCMCIA_VENDOR_TDK, PCMCIA_PRODUCT_TDK_LAK_DFL9610,
|
||||
1, 0,
|
||||
PCMCIA_STR_TDK_LAK_DFL9610 }
|
||||
{ { PCMCIA_STR_TDK_LAK_DFL9610, PCMCIA_VENDOR_TDK,
|
||||
PCMCIA_PRODUCT_TDK_LAK_DFL9610, 1 },
|
||||
0 },
|
||||
#endif
|
||||
|
||||
{ PCMCIA_VENDOR_CONTEC, PCMCIA_PRODUCT_CONTEC_CNETPC,
|
||||
0, 0,
|
||||
PCMCIA_STR_CONTEC_CNETPC },
|
||||
{ { PCMCIA_STR_CONTEC_CNETPC, PCMCIA_VENDOR_CONTEC,
|
||||
PCMCIA_PRODUCT_CONTEC_CNETPC, 0 },
|
||||
0 },
|
||||
|
||||
{ PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_LA501,
|
||||
0, 0x20,
|
||||
PCMCIA_STR_FUJITSU_LA501 },
|
||||
{ { PCMCIA_STR_FUJITSU_LA501, PCMCIA_VENDOR_FUJITSU,
|
||||
PCMCIA_PRODUCT_FUJITSU_LA501, 0 },
|
||||
0x20 },
|
||||
|
||||
{ PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_LA10S,
|
||||
0, 0,
|
||||
PCMCIA_STR_FUJITSU_LA10S },
|
||||
{ { PCMCIA_STR_FUJITSU_LA10S, PCMCIA_VENDOR_FUJITSU,
|
||||
PCMCIA_PRODUCT_FUJITSU_LA10S, 0 },
|
||||
0 },
|
||||
|
||||
{ 0, 0,
|
||||
0, 0,
|
||||
NULL },
|
||||
{ { NULL } }
|
||||
};
|
||||
|
||||
const struct mbe_pcmcia_product *mbe_pcmcia_lookup
|
||||
__P((const struct pcmcia_attach_args *pa));
|
||||
|
||||
const struct mbe_pcmcia_product *
|
||||
mbe_pcmcia_lookup(pa)
|
||||
const struct pcmcia_attach_args *pa;
|
||||
{
|
||||
const struct mbe_pcmcia_product *mpp;
|
||||
|
||||
for (mpp = mbe_pcmcia_products; mpp->mpp_name != NULL; mpp++) {
|
||||
if (pa->manufacturer == mpp->mpp_vendor &&
|
||||
pa->product == mpp->mpp_product &&
|
||||
pa->pf->number == mpp->mpp_expfunc)
|
||||
return (mpp);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int
|
||||
mbe_pcmcia_match(parent, match, aux)
|
||||
struct device *parent;
|
||||
@ -151,7 +128,9 @@ mbe_pcmcia_match(parent, match, aux)
|
||||
{
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
|
||||
if (mbe_pcmcia_lookup(pa) != NULL)
|
||||
if (pcmcia_product_lookup(pa,
|
||||
(const struct pcmcia_product *)mbe_pcmcia_products,
|
||||
sizeof mbe_pcmcia_products[0], NULL) != NULL)
|
||||
return (1);
|
||||
|
||||
return (0);
|
||||
@ -170,7 +149,9 @@ mbe_pcmcia_attach(parent, self, aux)
|
||||
const struct mbe_pcmcia_product *mpp;
|
||||
int rv;
|
||||
|
||||
mpp = mbe_pcmcia_lookup(pa);
|
||||
mpp = (const struct mbe_pcmcia_product *)pcmcia_product_lookup(pa,
|
||||
(const struct pcmcia_product *)mbe_pcmcia_products,
|
||||
sizeof mbe_pcmcia_products[0], NULL);
|
||||
if (mpp == NULL) {
|
||||
printf("\n");
|
||||
panic("mbe_pcmcia_attach: impossible");
|
||||
@ -211,7 +192,7 @@ mbe_pcmcia_attach(parent, self, aux)
|
||||
return;
|
||||
}
|
||||
|
||||
printf(": %s\n", mpp->mpp_name);
|
||||
printf(": %s\n", mpp->mpp_product.pp_name);
|
||||
|
||||
/* Read station address from CIS. */
|
||||
rv = pcmcia_scan_cis(parent, mbe_pcmcia_get_enaddr, &pgea);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* $NetBSD: if_sm_pcmcia.c,v 1.19 2000/02/02 16:04:40 itojun Exp $ */
|
||||
/* $NetBSD: if_sm_pcmcia.c,v 1.20 2000/02/04 01:27:13 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
@ -114,43 +114,21 @@ int sm_pcmcia_funce_enaddr __P((struct device *, u_int8_t *));
|
||||
|
||||
int sm_pcmcia_lannid_ciscallback __P((struct pcmcia_tuple *, void *));
|
||||
|
||||
struct sm_pcmcia_product {
|
||||
u_int32_t spp_vendor; /* vendor ID */
|
||||
u_int32_t spp_product; /* product ID */
|
||||
int spp_expfunc; /* expected function */
|
||||
const char *spp_name; /* product name */
|
||||
} sm_pcmcia_products[] = {
|
||||
{ PCMCIA_VENDOR_MEGAHERTZ2, PCMCIA_PRODUCT_MEGAHERTZ2_XJACK,
|
||||
0, PCMCIA_STR_MEGAHERTZ2_XJACK },
|
||||
const struct pcmcia_product sm_pcmcia_products[] = {
|
||||
{ PCMCIA_STR_MEGAHERTZ2_XJACK, PCMCIA_VENDOR_MEGAHERTZ2,
|
||||
PCMCIA_PRODUCT_MEGAHERTZ2_XJACK, 0, },
|
||||
|
||||
{ PCMCIA_VENDOR_NEWMEDIA, PCMCIA_PRODUCT_NEWMEDIA_BASICS,
|
||||
0, PCMCIA_STR_NEWMEDIA_BASICS },
|
||||
{ PCMCIA_STR_NEWMEDIA_BASICS, PCMCIA_VENDOR_NEWMEDIA,
|
||||
PCMCIA_PRODUCT_NEWMEDIA_BASICS, 0, },
|
||||
|
||||
#if 0
|
||||
{ PCMCIA_VENDOR_SMC, PCMCIA_PRODUCT_SMC_8020BT,
|
||||
0, PCMCIA_STR_SMC_8020BT },
|
||||
{ PCMCIA_STR_SMC_8020BT, PCMCIA_VENDOR_SMC,
|
||||
PCMCIA_PRODUCT_SMC_8020BT, 0, },
|
||||
#endif
|
||||
|
||||
{ 0, 0,
|
||||
0, NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
struct sm_pcmcia_product *sm_pcmcia_lookup __P((struct pcmcia_attach_args *));
|
||||
|
||||
struct sm_pcmcia_product *
|
||||
sm_pcmcia_lookup(pa)
|
||||
struct pcmcia_attach_args *pa;
|
||||
{
|
||||
struct sm_pcmcia_product *spp;
|
||||
|
||||
for (spp = sm_pcmcia_products; spp->spp_name != NULL; spp++)
|
||||
if (pa->manufacturer == spp->spp_vendor &&
|
||||
pa->product == spp->spp_product &&
|
||||
pa->pf->number == spp->spp_expfunc)
|
||||
return (spp);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int
|
||||
sm_pcmcia_match(parent, match, aux)
|
||||
struct device *parent;
|
||||
@ -159,7 +137,8 @@ sm_pcmcia_match(parent, match, aux)
|
||||
{
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
|
||||
if (sm_pcmcia_lookup(pa) != NULL)
|
||||
if (pcmcia_product_lookup(pa, sm_pcmcia_products,
|
||||
sizeof sm_pcmcia_products[0], NULL) != NULL)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
@ -174,7 +153,7 @@ sm_pcmcia_attach(parent, self, aux)
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
struct pcmcia_config_entry *cfe;
|
||||
u_int8_t myla[ETHER_ADDR_LEN], *enaddr = NULL;
|
||||
struct sm_pcmcia_product *spp;
|
||||
const struct pcmcia_product *pp;
|
||||
|
||||
psc->sc_configured = 0;
|
||||
|
||||
@ -213,11 +192,12 @@ sm_pcmcia_attach(parent, self, aux)
|
||||
return;
|
||||
}
|
||||
|
||||
spp = sm_pcmcia_lookup(pa);
|
||||
if (spp == NULL)
|
||||
pp = pcmcia_product_lookup(pa, sm_pcmcia_products,
|
||||
sizeof sm_pcmcia_products[0], NULL);
|
||||
if (pp == NULL)
|
||||
panic("sm_pcmcia_attach: impossible");
|
||||
|
||||
printf(": %s\n", spp->spp_name);
|
||||
printf(": %s\n", pp->pp_name);
|
||||
|
||||
/*
|
||||
* First try to get the Ethernet address from FUNCE/LANNID tuple.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* $NetBSD: mhzc.c,v 1.3 1999/10/20 14:57:57 enami Exp $ */
|
||||
/* $NetBSD: mhzc.c,v 1.4 2000/02/04 01:27:13 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
@ -142,11 +142,8 @@ struct cfattach mhzc_ca = {
|
||||
int mhzc_em3336_enaddr __P((struct mhzc_softc *, u_int8_t *));
|
||||
int mhzc_em3336_enable __P((struct mhzc_softc *));
|
||||
|
||||
struct mhzc_product {
|
||||
u_int32_t mp_vendor; /* PCMCIA vendor ID */
|
||||
u_int32_t mp_product; /* PCMCIA product ID */
|
||||
int mp_expfunc; /* expected function number */
|
||||
const char *mp_name; /* device name */
|
||||
const struct mhzc_product {
|
||||
struct pcmcia_product mp_product;
|
||||
|
||||
/* Get the Ethernet address for this card. */
|
||||
int (*mp_enaddr) __P((struct mhzc_softc *, u_int8_t *));
|
||||
@ -154,8 +151,8 @@ struct mhzc_product {
|
||||
/* Perform any special `enable' magic. */
|
||||
int (*mp_enable) __P((struct mhzc_softc *));
|
||||
} mhzc_products[] = {
|
||||
{ PCMCIA_VENDOR_MEGAHERTZ, PCMCIA_PRODUCT_MEGAHERTZ_XJEM3336,
|
||||
0, PCMCIA_STR_MEGAHERTZ_XJEM3336,
|
||||
{ { PCMCIA_STR_MEGAHERTZ_XJEM3336, PCMCIA_VENDOR_MEGAHERTZ,
|
||||
PCMCIA_PRODUCT_MEGAHERTZ_XJEM3336, 0 },
|
||||
mhzc_em3336_enaddr, mhzc_em3336_enable },
|
||||
|
||||
/*
|
||||
@ -164,9 +161,7 @@ struct mhzc_product {
|
||||
* most of them work more or less the same way.
|
||||
*/
|
||||
|
||||
{ 0, 0,
|
||||
0, NULL,
|
||||
NULL, NULL },
|
||||
{ { NULL } }
|
||||
};
|
||||
|
||||
int mhzc_print __P((void *, const char *));
|
||||
@ -179,23 +174,6 @@ void mhzc_disable __P((struct mhzc_softc *, int));
|
||||
|
||||
int mhzc_intr __P((void *));
|
||||
|
||||
const struct mhzc_product *mhzc_lookup __P((const struct pcmcia_attach_args *));
|
||||
|
||||
const struct mhzc_product *
|
||||
mhzc_lookup(pa)
|
||||
const struct pcmcia_attach_args *pa;
|
||||
{
|
||||
const struct mhzc_product *mp;
|
||||
|
||||
for (mp = mhzc_products; mp->mp_name != NULL; mp++) {
|
||||
if (pa->manufacturer == mp->mp_vendor &&
|
||||
pa->product == mp->mp_product &&
|
||||
pa->pf->number == mp->mp_expfunc)
|
||||
return (mp);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int
|
||||
mhzc_match(parent, match, aux)
|
||||
struct device *parent;
|
||||
@ -204,7 +182,9 @@ mhzc_match(parent, match, aux)
|
||||
{
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
|
||||
if (mhzc_lookup(pa) != NULL)
|
||||
if (pcmcia_product_lookup(pa,
|
||||
(const struct pcmcia_product *)mhzc_products,
|
||||
sizeof mhzc_products[0], NULL) != NULL)
|
||||
return (10); /* beat `com' */
|
||||
|
||||
return (0);
|
||||
@ -221,13 +201,15 @@ mhzc_attach(parent, self, aux)
|
||||
|
||||
sc->sc_pf = pa->pf;
|
||||
|
||||
sc->sc_product = mhzc_lookup(pa);
|
||||
sc->sc_product = (const struct mhzc_product *)pcmcia_product_lookup(pa,
|
||||
(const struct pcmcia_product *)mhzc_products,
|
||||
sizeof mhzc_products[0], NULL);
|
||||
if (sc->sc_product == NULL) {
|
||||
printf("\n");
|
||||
panic("mhzc_attach: impossible");
|
||||
}
|
||||
|
||||
printf(": %s\n", sc->sc_product->mp_name);
|
||||
printf(": %s\n", sc->sc_product->mp_product.pp_name);
|
||||
|
||||
/*
|
||||
* The address decoders on these cards are wacky. The configuration
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pcmcia.c,v 1.15 2000/01/23 20:44:04 aymeric Exp $ */
|
||||
/* $NetBSD: pcmcia.c,v 1.16 2000/02/04 01:27:14 cgd Exp $ */
|
||||
|
||||
#define PCMCIADEBUG
|
||||
|
||||
@ -322,6 +322,41 @@ pcmcia_print(arg, pnp)
|
||||
return (UNCONF);
|
||||
}
|
||||
|
||||
const struct pcmcia_product *
|
||||
pcmcia_product_lookup(pa, tab, ent_size, matchfn)
|
||||
struct pcmcia_attach_args *pa;
|
||||
const struct pcmcia_product *tab;
|
||||
size_t ent_size;
|
||||
pcmcia_product_match_fn matchfn;
|
||||
{
|
||||
const struct pcmcia_product *ent;
|
||||
int matches;
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (sizeof *ent > ent_size)
|
||||
panic("pcmcia_product_lookup: bogus ent_size %d", ent_size);
|
||||
#endif
|
||||
|
||||
for (ent = tab;
|
||||
ent->pp_name != NULL;
|
||||
ent = (const struct pcmcia_product *)
|
||||
((const char *)ent + ent_size)) {
|
||||
|
||||
/* see if it matches vendor/product/function */
|
||||
matches = (pa->manufacturer == ent->pp_vendor) &&
|
||||
(pa->product == ent->pp_product) &&
|
||||
(pa->pf->number == ent->pp_expfunc);
|
||||
|
||||
/* if a separate match function is given, let it override */
|
||||
if (matchfn != NULL)
|
||||
matches = (*matchfn)(pa, ent, matches);
|
||||
|
||||
if (matches)
|
||||
return (ent);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int
|
||||
pcmcia_card_gettype(dev)
|
||||
struct device *dev;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pcmciavar.h,v 1.9 1998/12/29 09:00:28 marc Exp $ */
|
||||
/* $NetBSD: pcmciavar.h,v 1.10 2000/02/04 01:27:14 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Marc Horowitz. All rights reserved.
|
||||
@ -202,6 +202,21 @@ struct pcmcia_tuple {
|
||||
bus_space_handle_t memh;
|
||||
};
|
||||
|
||||
struct pcmcia_product {
|
||||
const char *pp_name; /* NULL if end of table */
|
||||
u_int32_t pp_vendor;
|
||||
u_int32_t pp_product;
|
||||
int pp_expfunc;
|
||||
};
|
||||
|
||||
typedef int (*pcmcia_product_match_fn) __P((struct pcmcia_attach_args *pa,
|
||||
const struct pcmcia_product *ent, int vpfmatch));
|
||||
|
||||
const struct pcmcia_product
|
||||
*pcmcia_product_lookup __P((struct pcmcia_attach_args *pa,
|
||||
const struct pcmcia_product *tab, size_t ent_size,
|
||||
pcmcia_product_match_fn matchfn));
|
||||
|
||||
void pcmcia_read_cis __P((struct pcmcia_softc *));
|
||||
void pcmcia_check_cis_quirks __P((struct pcmcia_softc *));
|
||||
void pcmcia_print_cis __P((struct pcmcia_softc *));
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* $NetBSD: pcmcom.c,v 1.4 1998/11/20 05:20:20 thorpej Exp $ */
|
||||
/* $NetBSD: pcmcom.c,v 1.5 2000/02/04 01:27:14 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
@ -104,20 +104,15 @@ struct cfattach pcmcom_ca = {
|
||||
pcmcom_detach, pcmcom_activate
|
||||
};
|
||||
|
||||
struct pcmcom_product {
|
||||
u_int32_t pp_vendor; /* PCMCIA vendor ID */
|
||||
u_int32_t pp_product; /* PCMCIA product ID */
|
||||
int pp_expfunc; /* expected function number */
|
||||
const struct pcmcom_product {
|
||||
struct pcmcia_product pp_product;
|
||||
int pp_nslaves; /* number of slaves */
|
||||
const char *pp_name; /* device name */
|
||||
} pcmcom_products[] = {
|
||||
{ PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_DUAL_RS232,
|
||||
0, 2,
|
||||
PCMCIA_STR_SOCKET_DUAL_RS232 },
|
||||
{ { PCMCIA_STR_SOCKET_DUAL_RS232, PCMCIA_VENDOR_SOCKET,
|
||||
PCMCIA_PRODUCT_SOCKET_DUAL_RS232, 0 },
|
||||
2 },
|
||||
|
||||
{ 0, 0,
|
||||
0, 0,
|
||||
NULL },
|
||||
{ { NULL } }
|
||||
};
|
||||
|
||||
int pcmcom_print __P((void *, const char *));
|
||||
@ -132,23 +127,6 @@ void pcmcom_disable __P((struct pcmcom_softc *));
|
||||
|
||||
int pcmcom_intr __P((void *));
|
||||
|
||||
struct pcmcom_product *pcmcom_lookup __P((struct pcmcia_attach_args *));
|
||||
|
||||
struct pcmcom_product *
|
||||
pcmcom_lookup(pa)
|
||||
struct pcmcia_attach_args *pa;
|
||||
{
|
||||
struct pcmcom_product *pp;
|
||||
|
||||
for (pp = pcmcom_products; pp->pp_name != NULL; pp++)
|
||||
if (pa->manufacturer == pp->pp_vendor &&
|
||||
pa->product == pp->pp_product &&
|
||||
pa->pf->number == pp->pp_expfunc)
|
||||
return (pp);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int
|
||||
pcmcom_match(parent, cf, aux)
|
||||
struct device *parent;
|
||||
@ -157,7 +135,9 @@ pcmcom_match(parent, cf, aux)
|
||||
{
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
|
||||
if (pcmcom_lookup(pa) != NULL)
|
||||
if (pcmcia_product_lookup(pa,
|
||||
(const struct pcmcia_product *)pcmcom_products,
|
||||
sizeof pcmcom_products[0], NULL) != NULL)
|
||||
return (10); /* beat com_pcmcia */
|
||||
return (0);
|
||||
}
|
||||
@ -170,19 +150,21 @@ pcmcom_attach(parent, self, aux)
|
||||
struct pcmcom_softc *sc = (struct pcmcom_softc *)self;
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
struct pcmcia_config_entry *cfe;
|
||||
struct pcmcom_product *pp;
|
||||
const struct pcmcom_product *pp;
|
||||
size_t size;
|
||||
int i;
|
||||
|
||||
sc->sc_pf = pa->pf;
|
||||
|
||||
pp = pcmcom_lookup(pa);
|
||||
pp = (const struct pcmcom_product *)pcmcia_product_lookup(pa,
|
||||
(const struct pcmcia_product *)pcmcom_products,
|
||||
sizeof pcmcom_products[0], NULL);
|
||||
if (pp == NULL) {
|
||||
printf("\n");
|
||||
panic("pcmcom_attach: impossible");
|
||||
}
|
||||
|
||||
printf(": %s\n", pp->pp_name);
|
||||
printf(": %s\n", pp->pp_product.pp_name);
|
||||
|
||||
/* Allocate the slave info. */
|
||||
sc->sc_nslaves = pp->pp_nslaves;
|
||||
|
Loading…
Reference in New Issue
Block a user