From bc83c57ba7c92d1523020d8eeee3e432aaf72bb0 Mon Sep 17 00:00:00 2001 From: mav Date: Mon, 9 Mar 2009 20:48:57 +0000 Subject: Add type specific suspend/resume ata channel functions. Add checks to avoid crash on detached channel resume. Add placeholder for possible type-specific suspend/resume routines. --- sys/dev/ata/ata-pci.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'sys/dev/ata/ata-pci.c') diff --git a/sys/dev/ata/ata-pci.c b/sys/dev/ata/ata-pci.c index c2f2953..97261d2 100644 --- a/sys/dev/ata/ata-pci.c +++ b/sys/dev/ata/ata-pci.c @@ -581,6 +581,28 @@ ata_pcichannel_detach(device_t dev) return (0); } +static int +ata_pcichannel_suspend(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + + if (!ch->attached) + return (0); + + return ata_suspend(dev); +} + +static int +ata_pcichannel_resume(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + + if (!ch->attached) + return (0); + + return ata_resume(dev); +} + static int ata_pcichannel_locking(device_t dev, int mode) @@ -629,8 +651,8 @@ static device_method_t ata_pcichannel_methods[] = { DEVMETHOD(device_attach, ata_pcichannel_attach), DEVMETHOD(device_detach, ata_pcichannel_detach), DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, ata_suspend), - DEVMETHOD(device_resume, ata_resume), + DEVMETHOD(device_suspend, ata_pcichannel_suspend), + DEVMETHOD(device_resume, ata_pcichannel_resume), /* ATA methods */ DEVMETHOD(ata_setmode, ata_pcichannel_setmode), -- cgit v1.1