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.
This commit is contained in:
Alexander Motin 2009-03-09 20:48:57 +00:00
parent 0f6e8f934f
commit 79ca9100fd
3 changed files with 73 additions and 6 deletions

View File

@ -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),

View File

@ -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 }
};

View File

@ -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),