aboutsummaryrefslogtreecommitdiff
path: root/sys/sparc64/fhc/fhc.c
diff options
context:
space:
mode:
authorMarius Strobl <marius@FreeBSD.org>2009-03-19 20:29:23 +0000
committerMarius Strobl <marius@FreeBSD.org>2009-03-19 20:29:23 +0000
commit81099e6d93a7a3cc8ef40997579581e238db73fc (patch)
tree5ed3eaccde8aef3b9515da002bd65d07ee38a054 /sys/sparc64/fhc/fhc.c
parent652985b98f78b16dd55e65abb370e8d92500ae92 (diff)
downloadsrc-81099e6d93a7a3cc8ef40997579581e238db73fc.tar.gz
src-81099e6d93a7a3cc8ef40997579581e238db73fc.zip
- Failing to register as interrupt controller during attach shouldn't
be fatal so just inform about this instead of panicing. - Sort device methods. - Take advantage of KOBJMETHOD_END. - Remove some redundant variables.
Notes
Notes: svn path=/head/; revision=190098
Diffstat (limited to 'sys/sparc64/fhc/fhc.c')
-rw-r--r--sys/sparc64/fhc/fhc.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/sys/sparc64/fhc/fhc.c b/sys/sparc64/fhc/fhc.c
index 84edbd44e04f..f3e134a83e5c 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 **)&reg);
- 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);
}