Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pcmcia replace the *_lookup table entry match/lookup...
details: https://anonhg.NetBSD.org/src/rev/478c3e995bf3
branches: trunk
changeset: 481696:478c3e995bf3
user: cgd <cgd%NetBSD.org@localhost>
date: Fri Feb 04 01:27:12 2000 +0000
description:
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.
diffstat:
sys/dev/pcmcia/aic_pcmcia.c | 55 +++++++++------------------
sys/dev/pcmcia/if_ep_pcmcia.c | 82 ++++++++++++++++-------------------------
sys/dev/pcmcia/if_mbe_pcmcia.c | 83 ++++++++++++++++-------------------------
sys/dev/pcmcia/if_sm_pcmcia.c | 54 ++++++++------------------
sys/dev/pcmcia/mhzc.c | 46 +++++++----------------
sys/dev/pcmcia/pcmcia.c | 37 ++++++++++++++++++-
sys/dev/pcmcia/pcmciavar.h | 17 ++++++++-
sys/dev/pcmcia/pcmcom.c | 50 ++++++++-----------------
8 files changed, 181 insertions(+), 243 deletions(-)
diffs (truncated from 739 to 300 lines):
diff -r da81dd3084f8 -r 478c3e995bf3 sys/dev/pcmcia/aic_pcmcia.c
--- a/sys/dev/pcmcia/aic_pcmcia.c Thu Feb 03 23:04:45 2000 +0000
+++ b/sys/dev/pcmcia/aic_pcmcia.c Fri Feb 04 01:27:12 2000 +0000
@@ -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,39 +71,18 @@
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 },
-
- { 0, 0,
- 0, NULL },
-};
+const struct pcmcia_product aic_pcmcia_products[] = {
+ { PCMCIA_STR_ADAPTEC_APA1460, PCMCIA_VENDOR_ADAPTEC,
+ PCMCIA_PRODUCT_ADAPTEC_APA1460, 0 },
-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;
+ { PCMCIA_STR_ADAPTEC_APA1460A, PCMCIA_VENDOR_ADAPTEC,
+ PCMCIA_PRODUCT_ADAPTEC_APA1460A, 0 },
- 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);
-}
+ { PCMCIA_STR_NEWMEDIA_BUSTOASTER, PCMCIA_VENDOR_NEWMEDIA,
+ PCMCIA_PRODUCT_NEWMEDIA_BUSTOASTER, 0 },
+
+ { NULL }
+};
int
aic_pcmcia_match(parent, match, aux)
@@ -113,7 +92,8 @@
{
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 @@
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 @@
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;
diff -r da81dd3084f8 -r 478c3e995bf3 sys/dev/pcmcia/if_ep_pcmcia.c
--- a/sys/dev/pcmcia/if_ep_pcmcia.c Thu Feb 03 23:04:45 2000 +0000
+++ b/sys/dev/pcmcia/if_ep_pcmcia.c Fri Feb 04 01:27:12 2000 +0000
@@ -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,56 +141,37 @@
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_PRODUCT_3COM_3C574, ELINK_CHIPSET_ROADRUNNER,
- ELINK_FLAGS_MII, 0,
- PCMCIA_STR_3COM_3C574 },
+ { { PCMCIA_STR_3COM_3CXEM556, PCMCIA_VENDOR_3COM,
+ PCMCIA_PRODUCT_3COM_3CXEM556, 0 },
+ ELINK_CHIPSET_3C509, 0 },
- { PCMCIA_PRODUCT_3COM_3CCFEM556BI, ELINK_CHIPSET_ROADRUNNER,
- ELINK_FLAGS_MII, 0,
- PCMCIA_STR_3COM_3CCFEM556BI },
-
- { 0, 0,
- 0, 0,
- NULL },
-};
-
-struct ep_pcmcia_product *ep_pcmcia_lookup __P((struct pcmcia_attach_args *));
+ { { PCMCIA_STR_3COM_3CXEM556INT, PCMCIA_VENDOR_3COM,
+ PCMCIA_PRODUCT_3COM_3CXEM556INT, 0 },
+ ELINK_CHIPSET_3C509, 0 },
-struct ep_pcmcia_product *
-ep_pcmcia_lookup(pa)
- struct pcmcia_attach_args *pa;
-{
- struct ep_pcmcia_product *epp;
+ { { PCMCIA_STR_3COM_3C574, PCMCIA_VENDOR_3COM,
+ PCMCIA_PRODUCT_3COM_3C574, 0 },
+ ELINK_CHIPSET_ROADRUNNER, ELINK_FLAGS_MII },
- for (epp = ep_pcmcia_products; epp->epp_name != NULL; epp++)
- if (pa->product == epp->epp_product &&
- pa->pf->number == epp->epp_expfunc)
- return (epp);
+ { { PCMCIA_STR_3COM_3CCFEM556BI, PCMCIA_VENDOR_3COM,
+ PCMCIA_PRODUCT_3COM_3CCFEM556BI, 0 },
+ ELINK_CHIPSET_ROADRUNNER, ELINK_FLAGS_MII },
- return (NULL);
-}
+ { { NULL } }
+};
int
ep_pcmcia_match(parent, match, aux)
@@ -200,10 +181,9 @@
{
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 @@
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 @@
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;
diff -r da81dd3084f8 -r 478c3e995bf3 sys/dev/pcmcia/if_mbe_pcmcia.c
--- a/sys/dev/pcmcia/if_mbe_pcmcia.c Thu Feb 03 23:04:45 2000 +0000
+++ b/sys/dev/pcmcia/if_mbe_pcmcia.c Fri Feb 04 01:27:12 2000 +0000
@@ -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,60 +88,37 @@
};
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_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_LA501,
- 0, 0x20,
- PCMCIA_STR_FUJITSU_LA501 },
-
- { PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_LA10S,
- 0, 0,
- PCMCIA_STR_FUJITSU_LA10S },
-
- { 0, 0,
- 0, 0,
- NULL },
-};
+ { { PCMCIA_STR_CONTEC_CNETPC, PCMCIA_VENDOR_CONTEC,
+ PCMCIA_PRODUCT_CONTEC_CNETPC, 0 },
+ 0 },
-const struct mbe_pcmcia_product *mbe_pcmcia_lookup
- __P((const struct pcmcia_attach_args *pa));
-
-const struct mbe_pcmcia_product *
-mbe_pcmcia_lookup(pa)
Home |
Main Index |
Thread Index |
Old Index