diff --git a/sys/dev/ata/ata-cbus.c b/sys/dev/ata/ata-cbus.c index 98a0107c08cf..916be0d36f1b 100644 --- a/sys/dev/ata/ata-cbus.c +++ b/sys/dev/ata/ata-cbus.c @@ -313,6 +313,28 @@ ata_cbuschannel_detach(device_t dev) return ata_detach(dev); } +static int +ata_cbuschannel_suspend(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + + if (!ch->attached) + return (0); + + return ata_suspend(dev); +} + +static int +ata_cbuschannel_resume(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + + if (!ch->attached) + return (0); + + return ata_resume(dev); +} + static int ata_cbuschannel_banking(device_t dev, int flags) { @@ -360,8 +382,8 @@ static device_method_t ata_cbuschannel_methods[] = { DEVMETHOD(device_probe, ata_cbuschannel_probe), DEVMETHOD(device_attach, ata_cbuschannel_attach), DEVMETHOD(device_detach, ata_cbuschannel_detach), - DEVMETHOD(device_suspend, ata_suspend), - DEVMETHOD(device_resume, ata_resume), + DEVMETHOD(device_suspend, ata_cbuschannel_suspend), + DEVMETHOD(device_resume, ata_cbuschannel_resume), /* ATA methods */ DEVMETHOD(ata_locking, ata_cbuschannel_banking), diff --git a/sys/dev/ata/ata-isa.c b/sys/dev/ata/ata-isa.c index 6b1af81c5f12..b6c2cb2cfdcd 100644 --- a/sys/dev/ata/ata-isa.c +++ b/sys/dev/ata/ata-isa.c @@ -163,13 +163,36 @@ ata_isa_detach(device_t dev) return (error); } +static int +ata_isa_suspend(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + + if (!ch->attached) + return (0); + + return ata_suspend(dev); +} + +static int +ata_isa_resume(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + + if (!ch->attached) + return (0); + + return ata_resume(dev); +} + + static device_method_t ata_isa_methods[] = { /* device interface */ DEVMETHOD(device_probe, ata_isa_probe), DEVMETHOD(device_attach, ata_isa_attach), DEVMETHOD(device_detach, ata_isa_detach), - DEVMETHOD(device_suspend, ata_suspend), - DEVMETHOD(device_resume, ata_resume), + DEVMETHOD(device_suspend, ata_isa_suspend), + DEVMETHOD(device_resume, ata_isa_resume), { 0, 0 } }; diff --git a/sys/dev/ata/ata-pci.c b/sys/dev/ata/ata-pci.c index c2f295309a6c..97261d29f46f 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),