From aa3ee926a983b6ae9f630572f80a78852c151d05 Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Thu, 26 Jan 2006 21:14:32 +0000 Subject: [PATCH] - Register the generic implementations for the device shutdown, suspend and resume methods so these events propagate through the device driver hierarchy. - In dma(4) enable the chaining of the DMA engine interrupt handler for the LANCE devices via a dma_setup_intr(). This was commented out before as I was unsure whether I'd use it but this is probably cleaner than fiddling with the DMA engine interrupt in the LANCE driver directly. - In ebus_setup_dinfo() free 'intrs' instead of 'reg' twice in case setting up a child fails due to routing one of its interrupts fails. [1] Found by: Coverity Prevent [1] MFC after: 3 days --- sys/sparc64/central/central.c | 3 +++ sys/sparc64/ebus/ebus.c | 5 ++++- sys/sparc64/fhc/fhc_central.c | 3 +++ sys/sparc64/fhc/fhc_nexus.c | 3 +++ sys/sparc64/pci/psycho.c | 3 +++ sys/sparc64/sbus/dma_sbus.c | 11 +++-------- sys/sparc64/sbus/sbus.c | 3 +++ 7 files changed, 22 insertions(+), 9 deletions(-) diff --git a/sys/sparc64/central/central.c b/sys/sparc64/central/central.c index c078ef7ad91b..2d218b6c9a86 100644 --- a/sys/sparc64/central/central.c +++ b/sys/sparc64/central/central.c @@ -71,6 +71,9 @@ static device_method_t central_methods[] = { /* Device interface. */ DEVMETHOD(device_probe, central_probe), DEVMETHOD(device_attach, central_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), /* Bus interface. */ DEVMETHOD(bus_print_child, central_print_child), diff --git a/sys/sparc64/ebus/ebus.c b/sys/sparc64/ebus/ebus.c index 6825c7c72050..29a820090e5d 100644 --- a/sys/sparc64/ebus/ebus.c +++ b/sys/sparc64/ebus/ebus.c @@ -116,6 +116,9 @@ static device_method_t ebus_methods[] = { /* Device interface */ DEVMETHOD(device_probe, ebus_probe), DEVMETHOD(device_attach, ebus_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), /* Bus interface */ DEVMETHOD(bus_print_child, ebus_print_child), @@ -426,7 +429,7 @@ ebus_setup_dinfo(device_t dev, struct ebus_softc *sc, phandle_t node) device_printf(dev, "<%s>: could not map EBus interrupt %d\n", edi->edi_obdinfo.obd_name, intrs[i]); - free(reg, M_OFWPROP); + free(intrs, M_OFWPROP); goto fail; } resource_list_add(&edi->edi_rl, SYS_RES_IRQ, i, diff --git a/sys/sparc64/fhc/fhc_central.c b/sys/sparc64/fhc/fhc_central.c index 78a27e11f3e2..dfde113b036d 100644 --- a/sys/sparc64/fhc/fhc_central.c +++ b/sys/sparc64/fhc/fhc_central.c @@ -52,6 +52,9 @@ static device_method_t fhc_central_methods[] = { /* Device interface. */ DEVMETHOD(device_probe, fhc_central_probe), DEVMETHOD(device_attach, fhc_central_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), /* Bus interface. */ DEVMETHOD(bus_print_child, fhc_print_child), diff --git a/sys/sparc64/fhc/fhc_nexus.c b/sys/sparc64/fhc/fhc_nexus.c index 705c5c3dfb70..0a0406537ba9 100644 --- a/sys/sparc64/fhc/fhc_nexus.c +++ b/sys/sparc64/fhc/fhc_nexus.c @@ -55,6 +55,9 @@ static device_method_t fhc_nexus_methods[] = { /* Device interface. */ DEVMETHOD(device_probe, fhc_nexus_probe), DEVMETHOD(device_attach, fhc_nexus_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), /* Bus interface. */ DEVMETHOD(bus_print_child, fhc_print_child), diff --git a/sys/sparc64/pci/psycho.c b/sys/sparc64/pci/psycho.c index 322a058ad351..d79ed7151e7f 100644 --- a/sys/sparc64/pci/psycho.c +++ b/sys/sparc64/pci/psycho.c @@ -124,6 +124,9 @@ static device_method_t psycho_methods[] = { /* Device interface */ DEVMETHOD(device_probe, psycho_probe), DEVMETHOD(device_attach, psycho_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), /* Bus interface */ DEVMETHOD(bus_print_child, bus_generic_print_child), diff --git a/sys/sparc64/sbus/dma_sbus.c b/sys/sparc64/sbus/dma_sbus.c index 673dc3e5ab3f..d68b27b21ca6 100644 --- a/sys/sparc64/sbus/dma_sbus.c +++ b/sys/sparc64/sbus/dma_sbus.c @@ -105,9 +105,7 @@ static device_attach_t dma_attach; static bus_print_child_t dma_print_child; static bus_probe_nomatch_t dma_probe_nomatch; static bus_get_resource_list_t dma_get_resource_list; -#if 0 static bus_setup_intr_t dma_setup_intr; -#endif static ofw_bus_get_devinfo_t dma_get_devinfo; static struct dma_devinfo *dma_setup_dinfo(device_t, struct dma_softc *, @@ -119,15 +117,14 @@ static device_method_t dma_methods[] = { /* Device interface */ DEVMETHOD(device_probe, dma_probe), DEVMETHOD(device_attach, dma_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), /* Bus interface */ DEVMETHOD(bus_print_child, dma_print_child), DEVMETHOD(bus_probe_nomatch, dma_probe_nomatch), -#if 0 DEVMETHOD(bus_setup_intr, dma_setup_intr), -#else - DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), -#endif DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), @@ -404,7 +401,6 @@ dma_get_resource_list(device_t dev, device_t child) return (&ddi->ddi_rl); } -#if 0 static int dma_setup_intr(device_t dev, device_t child, struct resource *ires, int flags, driver_intr_t *intr, void *arg, void **cookiep) @@ -423,7 +419,6 @@ dma_setup_intr(device_t dev, device_t child, struct resource *ires, int flags, return (BUS_SETUP_INTR(device_get_parent(dev), child, ires, flags, intr, arg, cookiep)); } -#endif static const struct ofw_bus_devinfo * dma_get_devinfo(device_t bus, device_t child) diff --git a/sys/sparc64/sbus/sbus.c b/sys/sparc64/sbus/sbus.c index 472d76dd700b..7837bc7534d9 100644 --- a/sys/sparc64/sbus/sbus.c +++ b/sys/sparc64/sbus/sbus.c @@ -219,6 +219,9 @@ static device_method_t sbus_methods[] = { /* Device interface */ DEVMETHOD(device_probe, sbus_probe), DEVMETHOD(device_attach, sbus_attach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), /* Bus interface */ DEVMETHOD(bus_print_child, sbus_print_child),