Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/eisa Use eisa_compatible_{match,lookup}().



details:   https://anonhg.NetBSD.org/src/rev/232baca798b7
branches:  trunk
changeset: 958983:232baca798b7
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Jan 27 04:35:15 2021 +0000

description:
Use eisa_compatible_{match,lookup}().

diffstat:

 sys/dev/eisa/ahb.c         |   36 ++++-----
 sys/dev/eisa/ahc_eisa.c    |   27 ++++---
 sys/dev/eisa/bha_eisa.c    |   28 ++++---
 sys/dev/eisa/cac_eisa.c    |   77 ++++++++++++++--------
 sys/dev/eisa/dpt_eisa.c    |   45 +++++-------
 sys/dev/eisa/if_ep_eisa.c  |  154 +++++++++++++++++++++++++++-----------------
 sys/dev/eisa/if_tlp_eisa.c |   54 ++++++---------
 sys/dev/eisa/mlx_eisa.c    |   53 ++++++---------
 sys/dev/eisa/uha_eisa.c    |   24 ++++--
 9 files changed, 266 insertions(+), 232 deletions(-)

diffs (truncated from 932 to 300 lines):

diff -r 0fb7fb22c0c2 -r 232baca798b7 sys/dev/eisa/ahb.c
--- a/sys/dev/eisa/ahb.c        Wed Jan 27 04:31:36 2021 +0000
+++ b/sys/dev/eisa/ahb.c        Wed Jan 27 04:35:15 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahb.c,v 1.64 2016/07/14 04:00:45 msaitoh Exp $ */
+/*     $NetBSD: ahb.c,v 1.65 2021/01/27 04:35:15 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahb.c,v 1.64 2016/07/14 04:00:45 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahb.c,v 1.65 2021/01/27 04:35:15 thorpej Exp $");
 
 #include "opt_ddb.h"
 
@@ -142,6 +142,14 @@
 
 #define        AHB_ABORT_TIMEOUT       2000    /* time to wait for abort (mSec) */
 
+static const struct device_compatible_entry compat_data[] = {
+       { .compat = "ADP0000",  .data = EISA_PRODUCT_ADP0000 },
+       { .compat = "ADP0001",  .data = EISA_PRODUCT_ADP0001 },
+       { .compat = "ADP0002",  .data = EISA_PRODUCT_ADP0002 },
+       { .compat = "ADP0400",  .data = EISA_PRODUCT_ADP0400 },
+       DEVICE_COMPAT_EOL
+};
+
 /*
  * Check the slots looking for a board we recognise
  * If we find one, note its address (slot) and call
@@ -155,11 +163,7 @@
        bus_space_handle_t ioh;
        int rv;
 
-       /* must match one of our known ID strings */
-       if (strcmp(ea->ea_idstring, "ADP0000") &&
-           strcmp(ea->ea_idstring, "ADP0001") &&
-           strcmp(ea->ea_idstring, "ADP0002") &&
-           strcmp(ea->ea_idstring, "ADP0400"))
+       if (!eisa_compatible_match(ea, compat_data))
                return (0);
 
        if (bus_space_map(iot,
@@ -182,11 +186,12 @@
 {
        struct eisa_attach_args *ea = aux;
        struct ahb_softc *sc = device_private(self);
+       const struct device_compatible_entry *dce;
        bus_space_tag_t iot = ea->ea_iot;
        bus_space_handle_t ioh;
        eisa_chipset_tag_t ec = ea->ea_ec;
        eisa_intr_handle_t ih;
-       const char *model, *intrstr;
+       const char *intrstr;
        struct ahb_probe_data apd;
        struct scsipi_adapter *adapt = &sc->sc_adapter;
        struct scsipi_channel *chan = &sc->sc_channel;
@@ -194,18 +199,11 @@
 
        sc->sc_dev = self;
 
-       if (!strcmp(ea->ea_idstring, "ADP0000"))
-               model = EISA_PRODUCT_ADP0000;
-       else if (!strcmp(ea->ea_idstring, "ADP0001"))
-               model = EISA_PRODUCT_ADP0001;
-       else if (!strcmp(ea->ea_idstring, "ADP0002"))
-               model = EISA_PRODUCT_ADP0002;
-       else if (!strcmp(ea->ea_idstring, "ADP0400"))
-               model = EISA_PRODUCT_ADP0400;
-       else
-               model = "unknown model!";
+       dce = eisa_compatible_lookup(ea, compat_data);
+       KASSERT(dce != NULL);
+
        aprint_naive("\n");
-       aprint_normal(": %s\n", model);
+       aprint_normal(": %s\n", (const char *)dce->data);
 
        if (bus_space_map(iot,
            EISA_SLOT_ADDR(ea->ea_slot) + AHB_EISA_SLOT_OFFSET,
diff -r 0fb7fb22c0c2 -r 232baca798b7 sys/dev/eisa/ahc_eisa.c
--- a/sys/dev/eisa/ahc_eisa.c   Wed Jan 27 04:31:36 2021 +0000
+++ b/sys/dev/eisa/ahc_eisa.c   Wed Jan 27 04:35:15 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahc_eisa.c,v 1.41 2016/07/11 11:31:50 msaitoh Exp $    */
+/*     $NetBSD: ahc_eisa.c,v 1.42 2021/01/27 04:35:15 thorpej Exp $    */
 
 /*
  * Product specific probe and attach routines for:
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahc_eisa.c,v 1.41 2016/07/11 11:31:50 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahc_eisa.c,v 1.42 2021/01/27 04:35:15 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -63,6 +63,12 @@
 CFATTACH_DECL_NEW(ahc_eisa, sizeof(struct ahc_softc),
     ahc_eisa_match, ahc_eisa_attach, NULL, NULL);
 
+static const struct device_compatible_entry compat_data[] = {
+       { .compat = "ADP7770",  .data = EISA_PRODUCT_ADP7770 },
+       { .compat = "ADP7771",  .data = EISA_PRODUCT_ADP7771 },
+       DEVICE_COMPAT_EOL
+};
+
 /*
  * Check the slots looking for a board we recognise
  * If we find one, note its address (slot) and call
@@ -76,9 +82,7 @@
        bus_space_handle_t ioh;
        int irq;
 
-       /* must match one of our known ID strings */
-       if (strcmp(ea->ea_idstring, "ADP7770") &&
-           strcmp(ea->ea_idstring, "ADP7771"))
+       if (!eisa_compatible_match(ea, compat_data))
                return (0);
 
        if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) +
@@ -97,6 +101,7 @@
 {
        struct ahc_softc *ahc = device_private(self);
        struct eisa_attach_args *ea = aux;
+       const struct device_compatible_entry *dce;
        eisa_chipset_tag_t ec = ea->ea_ec;
        eisa_intr_handle_t ih;
        bus_space_tag_t iot = ea->ea_iot;
@@ -114,6 +119,9 @@
 
        ahc->sc_dev = self;
 
+       dce = eisa_compatible_lookup(ea, compat_data);
+       KASSERT(dce != NULL);
+
        if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) +
            AHC_EISA_SLOT_OFFSET, AHC_EISA_IOSIZE, 0, &ioh)) {
                aprint_error_dev(ahc->sc_dev, "could not map I/O addresses");
@@ -124,14 +132,7 @@
                goto free_io;
        }
 
-       if (strcmp(ea->ea_idstring, "ADP7770") == 0) {
-               printf(": %s\n", EISA_PRODUCT_ADP7770);
-       } else if (strcmp(ea->ea_idstring, "ADP7771") == 0) {
-               printf(": %s\n", EISA_PRODUCT_ADP7771);
-       } else {
-               printf(": Unknown device type %s", ea->ea_idstring);
-               goto free_io;
-       }
+       printf(": %s\n", (const char *)dce->data);
 
        ahc_set_name(ahc, device_xname(ahc->sc_dev));
        ahc->parent_dmat = ea->ea_dmat;
diff -r 0fb7fb22c0c2 -r 232baca798b7 sys/dev/eisa/bha_eisa.c
--- a/sys/dev/eisa/bha_eisa.c   Wed Jan 27 04:31:36 2021 +0000
+++ b/sys/dev/eisa/bha_eisa.c   Wed Jan 27 04:35:15 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bha_eisa.c,v 1.37 2014/10/18 08:33:27 snj Exp $        */
+/*     $NetBSD: bha_eisa.c,v 1.38 2021/01/27 04:35:15 thorpej Exp $    */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bha_eisa.c,v 1.37 2014/10/18 08:33:27 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bha_eisa.c,v 1.38 2021/01/27 04:35:15 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -93,6 +93,12 @@
        return (0);
 }
 
+static const struct device_compatible_entry compat_data[] = {
+       { .compat = "BUS4201",  .data = EISA_PRODUCT_BUS4201 },
+       { .compat = "BUS4202",  .data = EISA_PRODUCT_BUS4202 },
+       DEVICE_COMPAT_EOL
+};
+
 /*
  * Check the slots looking for a board we recognise
  * If we find one, note its address (slot) and call
@@ -107,9 +113,7 @@
        int port;
        int rv;
 
-       /* must match one of our known ID strings */
-       if (strcmp(ea->ea_idstring, "BUS4201") &&
-           strcmp(ea->ea_idstring, "BUS4202"))
+       if (!eisa_compatible_match(ea, compat_data))
                return (0);
 
        if (bus_space_map(iot,
@@ -139,24 +143,22 @@
 {
        struct eisa_attach_args *ea = aux;
        struct bha_softc *sc = device_private(self);
+       const struct device_compatible_entry *dce;
        bus_space_tag_t iot = ea->ea_iot;
        bus_space_handle_t ioh, ioh2;
        int port;
        struct bha_probe_data bpd;
        eisa_chipset_tag_t ec = ea->ea_ec;
        eisa_intr_handle_t ih;
-       const char *model, *intrstr;
+       const char *intrstr;
        char intrbuf[EISA_INTRSTR_LEN];
 
        sc->sc_dev = self;
 
-       if (!strcmp(ea->ea_idstring, "BUS4201"))
-               model = EISA_PRODUCT_BUS4201;
-       else if (!strcmp(ea->ea_idstring, "BUS4202"))
-               model = EISA_PRODUCT_BUS4202;
-       else
-               model = "unknown model!";
-       printf(": %s\n", model);
+       dce = eisa_compatible_lookup(ea, compat_data);
+       KASSERT(dce != NULL);
+
+       printf(": %s\n", (const char *)dce->data);
 
        if (bus_space_map(iot,
            EISA_SLOT_ADDR(ea->ea_slot) + BHA_EISA_SLOT_OFFSET, BHA_EISA_IOSIZE,
diff -r 0fb7fb22c0c2 -r 232baca798b7 sys/dev/eisa/cac_eisa.c
--- a/sys/dev/eisa/cac_eisa.c   Wed Jan 27 04:31:36 2021 +0000
+++ b/sys/dev/eisa/cac_eisa.c   Wed Jan 27 04:35:15 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cac_eisa.c,v 1.25 2016/09/27 03:33:32 pgoyette Exp $   */
+/*     $NetBSD: cac_eisa.c,v 1.26 2021/01/27 04:35:15 thorpej Exp $    */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cac_eisa.c,v 1.25 2016/09/27 03:33:32 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cac_eisa.c,v 1.26 2021/01/27 04:35:15 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -102,47 +102,68 @@
        cac_eisa_l0_submit
 };
 
-static struct cac_eisa_type {
-       const char      *ct_prodstr;
+struct cac_eisa_type {
        const char      *ct_typestr;
        const struct    cac_linkage *ct_linkage;
-} cac_eisa_type[] = {
-       { "CPQ4001",    "IDA",          &cac_eisa_l0 },
-       { "CPQ4002",    "IDA-2",        &cac_eisa_l0 },
-       { "CPQ4010",    "IEAS",         &cac_eisa_l0 },
-       { "CPQ4020",    "SMART",        &cac_eisa_l0 },
-       { "CPQ4030",    "SMART-2/E",    &cac_l0 },
+};
+
+static const struct cac_eisa_type cpq4001 = {
+       .ct_typestr = "IDA",
+       .ct_linkage = &cac_eisa_l0
+};
+
+static const struct cac_eisa_type cpq4002 = {
+       .ct_typestr = "IDA-2",
+       .ct_linkage = &cac_eisa_l0
+};
+
+static const struct cac_eisa_type cpq4010 = {
+       .ct_typestr = "IEAS",
+       .ct_linkage = &cac_eisa_l0
+};
+
+static const struct cac_eisa_type cpq4020 = {
+       .ct_typestr = "SMART",
+       .ct_linkage = &cac_eisa_l0
+};
+
+static const struct cac_eisa_type cpq4030 = {
+       .ct_typestr = "SMART-2/E",
+       .ct_linkage = &cac_l0
+};
+
+static const struct device_compatible_entry compat_data[] = {
+       { .compat = "CPQ4001",  .data = &cpq4001 },
+       { .compat = "CPQ4002",  .data = &cpq4002 },
+       { .compat = "CPQ4010",  .data = &cpq4010 },
+       { .compat = "CPQ4020",  .data = &cpq4020 },
+       { .compat = "CPQ4030",  .data = &cpq4030 },
+       DEVICE_COMPAT_EOL
 };



Home | Main Index | Thread Index | Old Index