Module Name: src Committed By: thorpej Date: Wed Jan 27 04:35:15 UTC 2021
Modified Files: src/sys/dev/eisa: ahb.c ahc_eisa.c bha_eisa.c cac_eisa.c dpt_eisa.c if_ep_eisa.c if_tlp_eisa.c mlx_eisa.c uha_eisa.c Log Message: Use eisa_compatible_{match,lookup}(). To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/dev/eisa/ahb.c cvs rdiff -u -r1.41 -r1.42 src/sys/dev/eisa/ahc_eisa.c cvs rdiff -u -r1.37 -r1.38 src/sys/dev/eisa/bha_eisa.c cvs rdiff -u -r1.25 -r1.26 src/sys/dev/eisa/cac_eisa.c cvs rdiff -u -r1.23 -r1.24 src/sys/dev/eisa/dpt_eisa.c cvs rdiff -u -r1.43 -r1.44 src/sys/dev/eisa/if_ep_eisa.c cvs rdiff -u -r1.27 -r1.28 src/sys/dev/eisa/if_tlp_eisa.c cvs rdiff -u -r1.26 -r1.27 src/sys/dev/eisa/mlx_eisa.c cvs rdiff -u -r1.38 -r1.39 src/sys/dev/eisa/uha_eisa.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/eisa/ahb.c diff -u src/sys/dev/eisa/ahb.c:1.64 src/sys/dev/eisa/ahb.c:1.65 --- src/sys/dev/eisa/ahb.c:1.64 Thu Jul 14 04:00:45 2016 +++ src/sys/dev/eisa/ahb.c Wed Jan 27 04:35:15 2021 @@ -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 @@ CFATTACH_DECL_NEW(ahb, sizeof(struct ahb #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 @@ ahbmatch(device_t parent, cfdata_t match 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 @@ ahbattach(device_t parent, device_t self { 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 @@ ahbattach(device_t parent, device_t self 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, Index: src/sys/dev/eisa/ahc_eisa.c diff -u src/sys/dev/eisa/ahc_eisa.c:1.41 src/sys/dev/eisa/ahc_eisa.c:1.42 --- src/sys/dev/eisa/ahc_eisa.c:1.41 Mon Jul 11 11:31:50 2016 +++ src/sys/dev/eisa/ahc_eisa.c Wed Jan 27 04:35:15 2021 @@ -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 @@ static void ahc_eisa_attach(device_t, de 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 @@ ahc_eisa_match(device_t parent, cfdata_t 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 @@ ahc_eisa_attach(device_t parent, device_ { 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_eisa_attach(device_t parent, device_ 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 @@ ahc_eisa_attach(device_t parent, device_ 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; Index: src/sys/dev/eisa/bha_eisa.c diff -u src/sys/dev/eisa/bha_eisa.c:1.37 src/sys/dev/eisa/bha_eisa.c:1.38 --- src/sys/dev/eisa/bha_eisa.c:1.37 Sat Oct 18 08:33:27 2014 +++ src/sys/dev/eisa/bha_eisa.c Wed Jan 27 04:35:15 2021 @@ -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 @@ bha_eisa_address(bus_space_tag_t iot, bu 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 @@ bha_eisa_match(device_t parent, cfdata_t 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 @@ bha_eisa_attach(device_t parent, device_ { 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, Index: src/sys/dev/eisa/cac_eisa.c diff -u src/sys/dev/eisa/cac_eisa.c:1.25 src/sys/dev/eisa/cac_eisa.c:1.26 --- src/sys/dev/eisa/cac_eisa.c:1.25 Tue Sep 27 03:33:32 2016 +++ src/sys/dev/eisa/cac_eisa.c Wed Jan 27 04:35:15 2021 @@ -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 @@ static const struct cac_linkage cac_eisa 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 }; static int cac_eisa_match(device_t parent, cfdata_t match, void *aux) { - struct eisa_attach_args *ea; - int i; + struct eisa_attach_args *ea = aux; - ea = aux; - - for (i = 0; i < sizeof(cac_eisa_type) / sizeof(cac_eisa_type[0]); i++) - if (strcmp(ea->ea_idstring, cac_eisa_type[i].ct_prodstr) == 0) - return (1); - - return (0); + return (eisa_compatible_match(ea, compat_data)); } static void cac_eisa_attach(device_t parent, device_t self, void *aux) { - struct eisa_attach_args *ea; + struct eisa_attach_args *ea = aux; + const struct device_compatible_entry *dce; + const struct cac_eisa_type *ct; bus_space_handle_t ioh; eisa_chipset_tag_t ec; eisa_intr_handle_t ih; struct cac_softc *sc; bus_space_tag_t iot; const char *intrstr; - int irq, i; + int irq; char intrbuf[EISA_INTRSTR_LEN]; - ea = aux; sc = device_private(self); iot = ea->ea_iot; ec = ea->ea_ec; @@ -153,6 +174,10 @@ cac_eisa_attach(device_t parent, device_ return; } + dce = eisa_compatible_lookup(ea, compat_data); + KASSERT(dce != NULL); + ct = dce->data; + sc->sc_dev = self; sc->sc_iot = iot; sc->sc_ioh = ioh; @@ -197,12 +222,8 @@ cac_eisa_attach(device_t parent, device_ /* * Print board type and attach to the bus-independent code. */ - for (i = 0; i < sizeof(cac_eisa_type) / sizeof(cac_eisa_type[0]); i++) - if (strcmp(ea->ea_idstring, cac_eisa_type[i].ct_prodstr) == 0) - break; - - aprint_normal(": Compaq %s\n", cac_eisa_type[i].ct_typestr); - memcpy(&sc->sc_cl, cac_eisa_type[i].ct_linkage, sizeof(sc->sc_cl)); + aprint_normal(": Compaq %s\n", ct->ct_typestr); + memcpy(&sc->sc_cl, ct->ct_linkage, sizeof(sc->sc_cl)); cac_init(sc, intrstr, 0); } Index: src/sys/dev/eisa/dpt_eisa.c diff -u src/sys/dev/eisa/dpt_eisa.c:1.23 src/sys/dev/eisa/dpt_eisa.c:1.24 --- src/sys/dev/eisa/dpt_eisa.c:1.23 Thu Jul 14 04:00:45 2016 +++ src/sys/dev/eisa/dpt_eisa.c Wed Jan 27 04:35:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: dpt_eisa.c,v 1.23 2016/07/14 04:00:45 msaitoh Exp $ */ +/* $NetBSD: dpt_eisa.c,v 1.24 2021/01/27 04:35:15 thorpej Exp $ */ /* * Copyright (c) 1999, 2000, 2001 Andrew Doran <a...@netbsd.org> @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dpt_eisa.c,v 1.23 2016/07/14 04:00:45 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dpt_eisa.c,v 1.24 2021/01/27 04:35:15 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -64,21 +64,21 @@ static int dpt_eisa_match(device_t, cfda CFATTACH_DECL_NEW(dpt_eisa, sizeof(struct dpt_softc), dpt_eisa_match, dpt_eisa_attach, NULL, NULL); -static const char * const dpt_eisa_boards[] = { - "DPT2402", - "DPTA401", - "DPTA402", - "DPTA410", - "DPTA411", - "DPTA412", - "DPTA420", - "DPTA501", - "DPTA502", - "DPTA701", - "DPTBC01", - "NEC8200", /* OEM */ - "ATT2408", /* OEM */ - NULL +static const struct device_compatible_entry compat_data[] = { + { .compat = "DPT2402" }, + { .compat = "DPTA401" }, + { .compat = "DPTA402" }, + { .compat = "DPTA410" }, + { .compat = "DPTA411" }, + { .compat = "DPTA412" }, + { .compat = "DPTA420" }, + { .compat = "DPTA501" }, + { .compat = "DPTA502" }, + { .compat = "DPTA701" }, + { .compat = "DPTBC01" }, + { .compat = "NEC8200" }, /* OEM */ + { .compat = "ATT2408" }, /* OEM */ + DEVICE_COMPAT_EOL }; static int @@ -105,16 +105,9 @@ dpt_eisa_irq(bus_space_tag_t iot, bus_sp static int dpt_eisa_match(device_t parent, cfdata_t match, void *aux) { - struct eisa_attach_args *ea; - int i; - - ea = aux; - - for (i = 0; dpt_eisa_boards[i] != NULL; i++) - if (strcmp(ea->ea_idstring, dpt_eisa_boards[i]) == 0) - break; + struct eisa_attach_args *ea = aux; - return (dpt_eisa_boards[i] != NULL); + return eisa_compatible_match(ea, compat_data); } static void Index: src/sys/dev/eisa/if_ep_eisa.c diff -u src/sys/dev/eisa/if_ep_eisa.c:1.43 src/sys/dev/eisa/if_ep_eisa.c:1.44 --- src/sys/dev/eisa/if_ep_eisa.c:1.43 Sat Mar 29 19:28:24 2014 +++ src/sys/dev/eisa/if_ep_eisa.c Wed Jan 27 04:35:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ep_eisa.c,v 1.43 2014/03/29 19:28:24 christos Exp $ */ +/* $NetBSD: if_ep_eisa.c,v 1.44 2021/01/27 04:35:15 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ep_eisa.c,v 1.43 2014/03/29 19:28:24 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ep_eisa.c,v 1.44 2021/01/27 04:35:15 thorpej Exp $"); #include "opt_inet.h" @@ -128,67 +128,104 @@ CFATTACH_DECL_NEW(ep_eisa, sizeof(struct #define EISA_ERROR 0x02 #define EISA_ENABLE 0x01 -static const struct ep_eisa_product { - const char *eep_eisaid; /* EISA ID */ - u_short eep_chipset; /* 3Com chipset used */ - int eep_flags; /* initial softc flags */ - const char *eep_name; /* device name */ -} ep_eisa_products[] = { - { "TCM5090", ELINK_CHIPSET_3C509, - 0, EISA_PRODUCT_TCM5090 }, - { "TCM5091", ELINK_CHIPSET_3C509, - 0, EISA_PRODUCT_TCM5091 }, - { "TCM5092", ELINK_CHIPSET_3C509, - 0, EISA_PRODUCT_TCM5092 }, - { "TCM5093", ELINK_CHIPSET_3C509, - 0, EISA_PRODUCT_TCM5093 }, - { "TCM5094", ELINK_CHIPSET_3C509, - 0, EISA_PRODUCT_TCM5094 }, - { "TCM5095", ELINK_CHIPSET_3C509, - 0, EISA_PRODUCT_TCM5095 }, - { "TCM5098", ELINK_CHIPSET_3C509, - 0, EISA_PRODUCT_TCM5098 }, - - /* - * Note: The 3c597 Fast Etherlink MII (TCM5972) is an - * MII connector for an external PHY. We treat it as - * `manual' in the core driver. - */ - { "TCM5920", ELINK_CHIPSET_VORTEX, - 0, EISA_PRODUCT_TCM5920 }, - { "TCM5970", ELINK_CHIPSET_VORTEX, - 0, EISA_PRODUCT_TCM5970 }, - { "TCM5971", ELINK_CHIPSET_VORTEX, - 0, EISA_PRODUCT_TCM5971 }, - { "TCM5972", ELINK_CHIPSET_VORTEX, - 0, EISA_PRODUCT_TCM5972 }, +struct ep_eisa_product { + u_short chipset; /* 3Com chipset used */ + int flags; /* initial softc flags */ + const char *name; /* device name */ +}; - { NULL, 0, - 0, NULL }, +static const struct ep_eisa_product tcm5090 = { + .chipset = ELINK_CHIPSET_3C509, + .flags = 0, + .name = EISA_PRODUCT_TCM5090 }; -static const struct ep_eisa_product * -ep_eisa_lookup(const struct eisa_attach_args *ea) -{ - const struct ep_eisa_product *eep; +static const struct ep_eisa_product tcm5091 = { + .chipset = ELINK_CHIPSET_3C509, + .flags = 0, + .name = EISA_PRODUCT_TCM5091 +}; - for (eep = ep_eisa_products; eep->eep_name != NULL; eep++) - if (strcmp(ea->ea_idstring, eep->eep_eisaid) == 0) - return (eep); +static const struct ep_eisa_product tcm5092 = { + .chipset = ELINK_CHIPSET_3C509, + .flags = 0, + .name = EISA_PRODUCT_TCM5092 +}; - return (NULL); -} +static const struct ep_eisa_product tcm5093 = { + .chipset = ELINK_CHIPSET_3C509, + .flags = 0, + .name = EISA_PRODUCT_TCM5093 +}; + +static const struct ep_eisa_product tcm5094 = { + .chipset = ELINK_CHIPSET_3C509, + .flags = 0, + .name = EISA_PRODUCT_TCM5094 +}; + +static const struct ep_eisa_product tcm5095 = { + .chipset = ELINK_CHIPSET_3C509, + .flags = 0, + .name = EISA_PRODUCT_TCM5095 +}; + +static const struct ep_eisa_product tcm5098 = { + .chipset = ELINK_CHIPSET_3C509, + .flags = 0, + .name = EISA_PRODUCT_TCM5098 +}; + +static const struct ep_eisa_product tcm5920 = { + .chipset = ELINK_CHIPSET_VORTEX, + .flags = 0, + .name = EISA_PRODUCT_TCM5920 +}; + +static const struct ep_eisa_product tcm5970 = { + .chipset = ELINK_CHIPSET_VORTEX, + .flags = 0, + .name = EISA_PRODUCT_TCM5970 +}; + +static const struct ep_eisa_product tcm5971 = { + .chipset = ELINK_CHIPSET_VORTEX, + .flags = 0, + .name = EISA_PRODUCT_TCM5971 +}; + +/* + * Note: The 3c597 Fast Etherlink MII (TCM5972) is an + * MII connector for an external PHY. We treat it as + * `manual' in the core driver. + */ +static const struct ep_eisa_product tcm5972 = { + .chipset = ELINK_CHIPSET_VORTEX, + .flags = 0, + .name = EISA_PRODUCT_TCM5972 +}; + +static const struct device_compatible_entry compat_data[] = { + { .compat = "TCM5090", .data = &tcm5090 }, + { .compat = "TCM5091", .data = &tcm5091 }, + { .compat = "TCM5092", .data = &tcm5092 }, + { .compat = "TCM5093", .data = &tcm5093 }, + { .compat = "TCM5094", .data = &tcm5094 }, + { .compat = "TCM5095", .data = &tcm5095 }, + { .compat = "TCM5098", .data = &tcm5098 }, + { .compat = "TCM5920", .data = &tcm5920 }, + { .compat = "TCM5970", .data = &tcm5970 }, + { .compat = "TCM5971", .data = &tcm5971 }, + { .compat = "TCM5972", .data = &tcm5972 }, + DEVICE_COMPAT_EOL +}; static int ep_eisa_match(device_t parent, cfdata_t match, void *aux) { struct eisa_attach_args *ea = aux; - /* must match one of our known ID strings */ - if (ep_eisa_lookup(ea) != NULL) - return (1); - - return (0); + return (eisa_compatible_match(ea, compat_data)); } static void @@ -196,6 +233,7 @@ ep_eisa_attach(device_t parent, device_t { struct ep_softc *sc = device_private(self); struct eisa_attach_args *ea = aux; + const struct device_compatible_entry *dce; bus_space_tag_t iot = ea->ea_iot; bus_space_handle_t ioh, ioh_cfg; eisa_chipset_tag_t ec = ea->ea_ec; @@ -227,11 +265,9 @@ ep_eisa_attach(device_t parent, device_t /* Read the IRQ from the card. */ irq = bus_space_read_2(iot, ioh_cfg, EP_EISA_CFG_RESOURCE) >> 12; - eep = ep_eisa_lookup(ea); - if (eep == NULL) { - printf("\n"); - panic("ep_eisa_attach: impossible"); - } + dce = eisa_compatible_lookup(ea, compat_data); + KASSERT(dce != NULL); + eep = dce->data; /* we don't need access to the config registers any more, but noone else should be able to map this space, so keep it @@ -240,14 +276,14 @@ ep_eisa_attach(device_t parent, device_t bus_space_unmap(iot, ioh_cfg, EP_EISA_CFG_SIZE); #endif - printf(": %s\n", eep->eep_name); + printf(": %s\n", eep->name); sc->enable = NULL; sc->disable = NULL; sc->enabled = 1; sc->bustype = ELINK_BUS_EISA; - sc->ep_flags = eep->eep_flags; + sc->ep_flags = eep->flags; if (eisa_intr_map(ec, irq, &ih)) { aprint_error_dev(sc->sc_dev, "couldn't map interrupt (%u)\n", @@ -267,5 +303,5 @@ ep_eisa_attach(device_t parent, device_t if (intrstr != NULL) aprint_normal_dev(sc->sc_dev, "interrupting at %s\n", intrstr); - epconfig(sc, eep->eep_chipset, NULL); + epconfig(sc, eep->chipset, NULL); } Index: src/sys/dev/eisa/if_tlp_eisa.c diff -u src/sys/dev/eisa/if_tlp_eisa.c:1.27 src/sys/dev/eisa/if_tlp_eisa.c:1.28 --- src/sys/dev/eisa/if_tlp_eisa.c:1.27 Thu Jul 14 04:00:45 2016 +++ src/sys/dev/eisa/if_tlp_eisa.c Wed Jan 27 04:35:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_tlp_eisa.c,v 1.27 2016/07/14 04:00:45 msaitoh Exp $ */ +/* $NetBSD: if_tlp_eisa.c,v 1.28 2021/01/27 04:35:15 thorpej Exp $ */ /*- * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_tlp_eisa.c,v 1.27 2016/07/14 04:00:45 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_tlp_eisa.c,v 1.28 2021/01/27 04:35:15 thorpej Exp $"); #include "opt_inet.h" @@ -109,29 +109,20 @@ CFATTACH_DECL_NEW(tlp_eisa, sizeof(struc static const int tlp_eisa_irqs[] = { 5, 9, 10, 11 }; -static const struct tulip_eisa_product { - const char *tep_eisaid; /* EISA ID */ - const char *tep_name; /* device name */ - tulip_chip_t tep_chip; /* base Tulip chip type */ -} tlp_eisa_products[] = { - { "DEC4250", "DEC DE425", - TULIP_CHIP_DE425 }, - - { NULL, NULL, - TULIP_CHIP_INVALID }, +struct tulip_eisa_product { + const char *name; /* device name */ + tulip_chip_t chip; /* base Tulip chip type */ }; -static const struct tulip_eisa_product * -tlp_eisa_lookup(const struct eisa_attach_args *ea) -{ - const struct tulip_eisa_product *tep; +static const struct tulip_eisa_product dec4250 = { + .name = "DEC DE425", + .chip = TULIP_CHIP_DE425, +}; - for (tep = tlp_eisa_products; - tep->tep_chip != TULIP_CHIP_INVALID; tep++) - if (strcmp(ea->ea_idstring, tep->tep_eisaid) == 0) - return (tep); - return (NULL); -} +static const struct device_compatible_entry compat_data[] = { + { .compat = "DEC4250", .data = &dec4250 }, + DEVICE_COMPAT_EOL +}; static int tlp_eisa_match(device_t parent, cfdata_t match, @@ -139,10 +130,7 @@ tlp_eisa_match(device_t parent, cfdata_t { struct eisa_attach_args *ea = aux; - if (tlp_eisa_lookup(ea) != NULL) - return (1); - - return (0); + return (eisa_compatible_match(ea, compat_data)); } static void @@ -153,6 +141,7 @@ tlp_eisa_attach(device_t parent, device_ struct tulip_eisa_softc *esc = device_private(self); struct tulip_softc *sc = &esc->sc_tulip; 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; @@ -177,12 +166,11 @@ tlp_eisa_attach(device_t parent, device_ sc->sc_st = iot; sc->sc_sh = ioh; - tep = tlp_eisa_lookup(ea); - if (tep == NULL) { - aprint_normal("\n"); - panic("tlp_eisa_attach: impossible"); - } - sc->sc_chip = tep->tep_chip; + dce = eisa_compatible_lookup(ea, compat_data); + KASSERT(dce != NULL); + tep = dce->data; + + sc->sc_chip = tep->chip; /* * DE425's registers are 16 bytes long; the PCI configuration @@ -210,7 +198,7 @@ tlp_eisa_attach(device_t parent, device_ sc->sc_rev = bus_space_read_4(iot, ioh, DE425_CFRV) & 0xff; aprint_normal(": %s Ethernet, pass %d.%d\n", - tep->tep_name, (sc->sc_rev >> 4) & 0xf, sc->sc_rev & 0xf); + tep->name, (sc->sc_rev >> 4) & 0xf, sc->sc_rev & 0xf); sc->sc_dmat = ea->ea_dmat; Index: src/sys/dev/eisa/mlx_eisa.c diff -u src/sys/dev/eisa/mlx_eisa.c:1.26 src/sys/dev/eisa/mlx_eisa.c:1.27 --- src/sys/dev/eisa/mlx_eisa.c:1.26 Tue Sep 27 03:33:32 2016 +++ src/sys/dev/eisa/mlx_eisa.c Wed Jan 27 04:35:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mlx_eisa.c,v 1.26 2016/09/27 03:33:32 pgoyette Exp $ */ +/* $NetBSD: mlx_eisa.c,v 1.27 2021/01/27 04:35:15 thorpej Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mlx_eisa.c,v 1.26 2016/09/27 03:33:32 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mlx_eisa.c,v 1.27 2021/01/27 04:35:15 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -80,50 +80,42 @@ static int mlx_v1_reset(struct mlx_softc CFATTACH_DECL3_NEW(mlx_eisa, sizeof(struct mlx_softc), mlx_eisa_match, mlx_eisa_attach, NULL, NULL, mlx_eisa_rescan, NULL, 0); -static struct mlx_eisa_prod { - const char *mp_idstr; - int mp_nchan; -} const mlx_eisa_prod[] = { - { "MLX0070", 1 }, - { "MLX0071", 3 }, - { "MLX0072", 3 }, - { "MLX0073", 2 }, - { "MLX0074", 1 }, - { "MLX0075", 3 }, - { "MLX0076", 2 }, - { "MLX0077", 1 }, +static const struct device_compatible_entry compat_data[] = { + /* nchan */ + { .compat = "MLX0070", .value = 1 }, + { .compat = "MLX0071", .value = 3 }, + { .compat = "MLX0072", .value = 3 }, + { .compat = "MLX0073", .value = 2 }, + { .compat = "MLX0074", .value = 1 }, + { .compat = "MLX0075", .value = 3 }, + { .compat = "MLX0076", .value = 2 }, + { .compat = "MLX0077", .value = 1 }, + DEVICE_COMPAT_EOL }; static int mlx_eisa_match(device_t parent, cfdata_t match, void *aux) { - struct eisa_attach_args *ea; - int i; - - ea = aux; - - for (i = 0; i < sizeof(mlx_eisa_prod) / sizeof(mlx_eisa_prod[0]); i++) - if (strcmp(ea->ea_idstring, mlx_eisa_prod[i].mp_idstr) == 0) - return (1); + struct eisa_attach_args *ea = aux; - return (0); + return (eisa_compatible_match(ea, compat_data)); } static void mlx_eisa_attach(device_t parent, device_t self, void *aux) { - struct eisa_attach_args *ea; + struct eisa_attach_args *ea = aux; + const struct device_compatible_entry *dce; bus_space_handle_t ioh; eisa_chipset_tag_t ec; eisa_intr_handle_t ih; struct mlx_softc *mlx; bus_space_tag_t iot; const char *intrstr; - int irq, i, icfg; + int irq, icfg; char intrbuf[EISA_INTRSTR_LEN]; - ea = aux; mlx = device_private(self); iot = ea->ea_iot; ec = ea->ea_ec; @@ -179,11 +171,10 @@ mlx_eisa_attach(device_t parent, device_ return; } - for (i = 0; i < sizeof(mlx_eisa_prod) / sizeof(mlx_eisa_prod[0]); i++) - if (strcmp(ea->ea_idstring, mlx_eisa_prod[i].mp_idstr) == 0) { - mlx->mlx_ci.ci_nchan = mlx_eisa_prod[i].mp_nchan; - break; - } + dce = eisa_compatible_lookup(ea, compat_data); + KASSERT(dce != NULL); + + mlx->mlx_ci.ci_nchan = (int)dce->value; mlx->mlx_ci.ci_iftype = 1; mlx->mlx_submit = mlx_v1_submit; Index: src/sys/dev/eisa/uha_eisa.c diff -u src/sys/dev/eisa/uha_eisa.c:1.38 src/sys/dev/eisa/uha_eisa.c:1.39 --- src/sys/dev/eisa/uha_eisa.c:1.38 Mon Jul 11 11:31:50 2016 +++ src/sys/dev/eisa/uha_eisa.c Wed Jan 27 04:35:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: uha_eisa.c,v 1.38 2016/07/11 11:31:50 msaitoh Exp $ */ +/* $NetBSD: uha_eisa.c,v 1.39 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: uha_eisa.c,v 1.38 2016/07/11 11:31:50 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uha_eisa.c,v 1.39 2021/01/27 04:35:15 thorpej Exp $"); #include "opt_ddb.h" @@ -73,6 +73,11 @@ static int u24_poll(struct uha_softc *, static int u24_intr(void *); static void u24_init(struct uha_softc *); +static const struct device_compatible_entry compat_data[] = { + { .compat = "USC024?", .data = EISA_PRODUCT_USC0240 }, + DEVICE_COMPAT_EOL +}; + /* * Check the slots looking for a board we recognise * If we find one, note its address (slot) and call @@ -87,8 +92,7 @@ uha_eisa_match(device_t parent, cfdata_t bus_space_handle_t ioh; int rv; - /* must match one of our known ID strings */ - if (strncmp(ea->ea_idstring, "USC024", 6)) + if (!eisa_compatible_match(ea, compat_data)) return (0); if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) + @@ -110,20 +114,20 @@ uha_eisa_attach(device_t parent, device_ { struct eisa_attach_args *ea = aux; struct uha_softc *sc = device_private(self); + const struct device_compatible_entry *dce; bus_space_tag_t iot = ea->ea_iot; bus_dma_tag_t dmat = ea->ea_dmat; bus_space_handle_t ioh; struct uha_probe_data upd; 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]; - if (!strncmp(ea->ea_idstring, "USC024", 6)) - model = EISA_PRODUCT_USC0240; - 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) + UHA_EISA_SLOT_OFFSET, UHA_EISA_IOSIZE, 0, &ioh))