diff options
-rw-r--r-- | sys/sparc64/fhc/fhc.c | 53 | ||||
-rw-r--r-- | sys/sparc64/sparc64/upa.c | 26 |
2 files changed, 41 insertions, 38 deletions
diff --git a/sys/sparc64/fhc/fhc.c b/sys/sparc64/fhc/fhc.c index 84edbd4..f3e134a 100644 --- a/sys/sparc64/fhc/fhc.c +++ b/sys/sparc64/fhc/fhc.c @@ -90,14 +90,14 @@ static device_method_t fhc_methods[] = { /* Bus interface */ DEVMETHOD(bus_print_child, fhc_print_child), DEVMETHOD(bus_probe_nomatch, fhc_probe_nomatch), - DEVMETHOD(bus_setup_intr, fhc_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), DEVMETHOD(bus_alloc_resource, fhc_alloc_resource), - DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_get_resource_list, fhc_get_resource_list), + DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_setup_intr, fhc_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_get_resource_list, fhc_get_resource_list), /* ofw_bus interface */ DEVMETHOD(ofw_bus_get_devinfo, fhc_get_devinfo), @@ -107,7 +107,7 @@ static device_method_t fhc_methods[] = { DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - { NULL, NULL } + KOBJMETHOD_END }; static driver_t fhc_driver = { @@ -165,9 +165,7 @@ fhc_attach(device_t dev) int central; int error; int i; - int nintr; - int nreg; - int rid; + int j; sc = device_get_softc(dev); node = ofw_bus_get_node(dev); @@ -177,9 +175,9 @@ fhc_attach(device_t dev) central = 1; for (i = 0; i < FHC_NREG; i++) { - rid = i; + j = i; sc->sc_memres[i] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &rid, RF_ACTIVE); + &j, RF_ACTIVE); if (sc->sc_memres[i] == NULL) { device_printf(dev, "cannot allocate resource %d\n", i); error = ENXIO; @@ -239,7 +237,8 @@ fhc_attach(device_t dev) /* * Hunt through all the interrupt mapping regs and register * our interrupt controller for the corresponding interrupt - * vectors. + * vectors. We do this early in order to be able to catch + * stray interrupts. */ for (i = FHC_FANFAIL; i <= FHC_TOD; i++) { fica = malloc(sizeof(*fica), M_DEVBUF, M_NOWAIT); @@ -259,11 +258,13 @@ fhc_attach(device_t dev) * the IGN and the IGN is constant for all devices * on that FireHose controller. */ - if (intr_controller_register(INTMAP_VEC(sc->sc_ign, + j = intr_controller_register(INTMAP_VEC(sc->sc_ign, INTINO(bus_read_4(fica->fica_memres, FHC_IMAP))), - &fhc_ic, fica) != 0) - panic("%s: could not register interrupt " - "controller for map %d", __func__, i); + &fhc_ic, fica); + if (j != 0) + device_printf(dev, "could not register " + "interrupt controller for map %d (%d)\n", + i, j); } } else { snprintf(ledname, sizeof(ledname), "board%d", board); @@ -276,9 +277,9 @@ fhc_attach(device_t dev) free(fdi, M_DEVBUF); continue; } - nreg = OF_getprop_alloc(child, "reg", sizeof(*reg), + i = OF_getprop_alloc(child, "reg", sizeof(*reg), (void **)®); - if (nreg == -1) { + if (i == -1) { device_printf(dev, "<%s>: incomplete\n", fdi->fdi_obdinfo.obd_name); ofw_bus_gen_destroy_devinfo(&fdi->fdi_obdinfo); @@ -286,19 +287,19 @@ fhc_attach(device_t dev) continue; } resource_list_init(&fdi->fdi_rl); - for (i = 0; i < nreg; i++) - resource_list_add(&fdi->fdi_rl, SYS_RES_MEMORY, i, - reg[i].sbr_offset, reg[i].sbr_offset + - reg[i].sbr_size, reg[i].sbr_size); + for (j = 0; j < i; j++) + resource_list_add(&fdi->fdi_rl, SYS_RES_MEMORY, j, + reg[j].sbr_offset, reg[j].sbr_offset + + reg[j].sbr_size, reg[j].sbr_size); free(reg, M_OFWPROP); if (central == 1) { - nintr = OF_getprop_alloc(child, "interrupts", + i = OF_getprop_alloc(child, "interrupts", sizeof(*intr), (void **)&intr); - if (nintr != -1) { - for (i = 0; i < nintr; i++) { - iv = INTMAP_VEC(sc->sc_ign, intr[i]); + if (i != -1) { + for (j = 0; j < i; j++) { + iv = INTMAP_VEC(sc->sc_ign, intr[j]); resource_list_add(&fdi->fdi_rl, - SYS_RES_IRQ, i, iv, iv, 1); + SYS_RES_IRQ, j, iv, iv, 1); } free(intr, M_OFWPROP); } diff --git a/sys/sparc64/sparc64/upa.c b/sys/sparc64/sparc64/upa.c index 06ae244..7069c68 100644 --- a/sys/sparc64/sparc64/upa.c +++ b/sys/sparc64/sparc64/upa.c @@ -144,7 +144,7 @@ static device_method_t upa_methods[] = { DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - { NULL, NULL } + KOBJMETHOD_END }; static devclass_t upa_devclass; @@ -241,7 +241,7 @@ upa_attach(device_t dev) "pci108e,8001") == 0 && ((bus_get_resource_start(children[j], SYS_RES_MEMORY, 0) >> 20) & 1) == 1) { - schizo = children[j]; + schizo = children[j]; break; } } @@ -287,9 +287,10 @@ upa_attach(device_t dev) goto fail; } - /* + /* * Hunt through all the interrupt mapping regs and register our * interrupt controller for the corresponding interrupt vectors. + * We do this early in order to be able to catch stray interrupts. */ for (i = UPA_INO_BASE; i <= UPA_INO_MAX; i++) { imr = 0; @@ -312,10 +313,11 @@ upa_attach(device_t dev) device_printf(dev, "intr map (INO %d) IMR%d: %#lx\n", i, imr, (u_long)UPA_READ(sc, imr, 0x0)); #endif - if (intr_controller_register(INTMAP_VEC(sc->sc_ign, i), - &upa_ic, uica) != 0) - panic("%s: could not register interrupt controller " - "for INO %d", __func__, i); + j = intr_controller_register(INTMAP_VEC(sc->sc_ign, i), + &upa_ic, uica); + if (j != 0) + device_printf(dev, "could not register interrupt " + "controller for INO %d (%d)\n", i, j); } /* Make sure the power level is appropriate for normal operation. */ @@ -345,13 +347,13 @@ upa_attach(device_t dev) device_printf(dev, "could not determine upa-portid of child 0x%lx\n", (unsigned long)child); - continue; + continue; } if (portid > 1) { device_printf(dev, "upa-portid %d of child 0x%lx invalid\n", portid, (unsigned long)child); - continue; + continue; } if ((udi = upa_setup_dinfo(dev, sc, child, portid)) == NULL) continue; @@ -493,12 +495,12 @@ upa_setup_intr(device_t dev, device_t child, struct resource *ires, int flags, /* * Make sure the vector is fully specified and we registered * our interrupt controller for it. - */ + */ vec = rman_get_start(ires); if (INTIGN(vec) != sc->sc_ign || intr_vectors[vec].iv_ic != &upa_ic) { device_printf(dev, "invalid interrupt vector 0x%lx\n", vec); - return (EINVAL); - } + return (EINVAL); + } return (bus_generic_setup_intr(dev, child, ires, flags, filt, func, arg, cookiep)); } |