svn commit: r189600 - head/sys/dev/ata

Alexander Motin mav at FreeBSD.org
Mon Mar 9 13:49:01 PDT 2009


Author: mav
Date: Mon Mar  9 20:48:57 2009
New Revision: 189600
URL: http://svn.freebsd.org/changeset/base/189600

Log:
  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.

Modified:
  head/sys/dev/ata/ata-cbus.c
  head/sys/dev/ata/ata-isa.c
  head/sys/dev/ata/ata-pci.c

Modified: head/sys/dev/ata/ata-cbus.c
==============================================================================
--- head/sys/dev/ata/ata-cbus.c	Mon Mar  9 20:08:08 2009	(r189599)
+++ head/sys/dev/ata/ata-cbus.c	Mon Mar  9 20:48:57 2009	(r189600)
@@ -314,6 +314,28 @@ ata_cbuschannel_detach(device_t 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)
 {
     struct ata_cbus_controller *ctlr = device_get_softc(device_get_parent(dev));
@@ -360,8 +382,8 @@ static device_method_t ata_cbuschannel_m
     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),

Modified: head/sys/dev/ata/ata-isa.c
==============================================================================
--- head/sys/dev/ata/ata-isa.c	Mon Mar  9 20:08:08 2009	(r189599)
+++ head/sys/dev/ata/ata-isa.c	Mon Mar  9 20:48:57 2009	(r189600)
@@ -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 }
 };

Modified: head/sys/dev/ata/ata-pci.c
==============================================================================
--- head/sys/dev/ata/ata-pci.c	Mon Mar  9 20:08:08 2009	(r189599)
+++ head/sys/dev/ata/ata-pci.c	Mon Mar  9 20:48:57 2009	(r189600)
@@ -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_me
     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),


More information about the svn-src-all mailing list