Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pcmcia Make the product lookup table driven.



details:   https://anonhg.NetBSD.org/src/rev/797a31263a1c
branches:  trunk
changeset: 481657:797a31263a1c
user:      enami <enami%NetBSD.org@localhost>
date:      Thu Feb 03 08:52:21 2000 +0000

description:
Make the product lookup table driven.

diffstat:

 sys/dev/pcmcia/if_awi_pcmcia.c |  62 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 58 insertions(+), 4 deletions(-)

diffs (104 lines):

diff -r c83b2230e116 -r 797a31263a1c sys/dev/pcmcia/if_awi_pcmcia.c
--- a/sys/dev/pcmcia/if_awi_pcmcia.c    Thu Feb 03 08:26:33 2000 +0000
+++ b/sys/dev/pcmcia/if_awi_pcmcia.c    Thu Feb 03 08:52:21 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_awi_pcmcia.c,v 1.9 2000/02/01 10:12:04 enami Exp $ */
+/* $NetBSD: if_awi_pcmcia.c,v 1.10 2000/02/03 08:52:21 enami Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -134,6 +134,56 @@
 };
 int    awi_pcmcia_get_enaddr __P((struct pcmcia_tuple *, void *));
 
+struct awi_pcmcia_product {
+       u_int32_t       app_vendor;     /* vendor ID */
+       u_int32_t       app_product;    /* product ID */
+       const char      *app_cisinfo[4]; /* CIS information */
+       const char      *app_name;      /* product name */
+} awi_pcmcia_products[] = {
+       { PCMCIA_VENDOR_BAY,            PCMCIA_PRODUCT_BAY_STACK_650,
+         PCMCIA_CIS_BAY_STACK_650,     PCMCIA_STR_BAY_STACK_650 },
+
+#ifdef notyet
+       { PCMCIA_VENDOR_MELCO,          PCMCIA_PRODUCT_MELCO_WLI_PCM,
+         PCMCIA_CIS_MELCO_WLI_PCM,     PCMCIA_STR_MELCO_WLI_PCM },
+
+       { PCMCIA_VENDOR_ICOM,           PCMCIA_PRODUCT_ICOM_SL200,
+         PCMCIA_CIS_ICOM_SL200,        PCMCIA_STR_ICOM_SL200 },
+#endif
+
+       { 0,                            0,
+         { NULL, NULL, NULL, NULL },   NULL },
+};
+
+struct awi_pcmcia_product *
+       awi_pcmcia_lookup __P((struct pcmcia_attach_args *));
+
+struct awi_pcmcia_product *
+awi_pcmcia_lookup(pa)
+       struct pcmcia_attach_args *pa;
+{
+       struct awi_pcmcia_product *app;
+
+       for (app = awi_pcmcia_products; app->app_name != NULL; app++) {
+               /* match by vendor/product id */
+               if (pa->manufacturer != PCMCIA_VENDOR_INVALID &&
+                   pa->manufacturer == app->app_vendor &&
+                   pa->product != PCMCIA_PRODUCT_INVALID &&
+                   pa->product == app->app_product)
+                       return (app);
+
+               /* match by CIS information */
+               if (pa->card->cis1_info[0] != NULL &&
+                   app->app_cisinfo[0] != NULL &&
+                   strcmp(pa->card->cis1_info[0], app->app_cisinfo[0]) == 0 &&
+                   pa->card->cis1_info[1] != NULL &&
+                   app->app_cisinfo[1] != NULL &&
+                   strcmp(pa->card->cis1_info[1], app->app_cisinfo[1]) == 0)
+                       return (app);
+       }
+
+       return (NULL);
+}
 
 int
 awi_pcmcia_enable(sc)
@@ -171,8 +221,7 @@
 {
        struct pcmcia_attach_args *pa = aux;
 
-       if (pa->manufacturer == PCMCIA_VENDOR_BAY &&
-           pa->product == PCMCIA_PRODUCT_BAY_STACK_650)
+       if (awi_pcmcia_lookup(pa) != NULL)
                return (1);
 
        return (0);
@@ -242,6 +291,7 @@
 {
        struct awi_pcmcia_softc *psc = (void *)self;
        struct awi_softc *sc = &psc->sc_awi;
+       struct awi_pcmcia_product *app;
        struct pcmcia_attach_args *pa = aux;
        struct pcmcia_config_entry *cfe;
        struct pcmcia_mem_handle memh;
@@ -277,6 +327,10 @@
        }
 #endif
 
+       app = awi_pcmcia_lookup(pa);
+       if (app == NULL)
+               panic("awi_pcmcia_attach: impossible");
+
        psc->sc_pf = pa->pf;
 
        for (cfe = SIMPLEQ_FIRST(&pa->pf->cfe_head); cfe != NULL;
@@ -298,7 +352,7 @@
 
        sc->sc_enabled = 1;
        sc->sc_state = AWI_ST_SELFTEST;
-       printf(": BayStack 650 Wireless (802.11)\n");
+       printf(": %s\n", app->app_name);
 
        if (pcmcia_mem_alloc(psc->sc_pf, AM79C930_MEM_SIZE, &memh) != 0) {
                printf("%s: unable to allocate memory space; using i/o only\n",



Home | Main Index | Thread Index | Old Index