Module Name:    src
Committed By:   tsutsui
Date:           Wed Sep  2 11:10:38 UTC 2009

Modified Files:
        src/sys/dev/ic: aic7xxx_osm.c
        src/sys/dev/pci: ahc_pci.c

Log Message:
Call pmf_device_register(9) in ahc_attahc() rather than ahc_pci_attach()
since pmf_device_deregister(9) is called from ahc_detach() so that
cardbus backend also gets proper pmf(9) calls.
PCI backend is tested on on O2, but cardbus is untested.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/ic/aic7xxx_osm.c
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/pci/ahc_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/aic7xxx_osm.c
diff -u src/sys/dev/ic/aic7xxx_osm.c:1.31 src/sys/dev/ic/aic7xxx_osm.c:1.32
--- src/sys/dev/ic/aic7xxx_osm.c:1.31	Sat May 16 06:44:05 2009
+++ src/sys/dev/ic/aic7xxx_osm.c	Wed Sep  2 11:10:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: aic7xxx_osm.c,v 1.31 2009/05/16 06:44:05 tsutsui Exp $	*/
+/*	$NetBSD: aic7xxx_osm.c,v 1.32 2009/09/02 11:10:37 tsutsui Exp $	*/
 
 /*
  * Bus independent FreeBSD shim for the aic7xxx based adaptec SCSI controllers
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aic7xxx_osm.c,v 1.31 2009/05/16 06:44:05 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aic7xxx_osm.c,v 1.32 2009/09/02 11:10:37 tsutsui Exp $");
 
 #include <dev/ic/aic7xxx_osm.h>
 #include <dev/ic/aic7xxx_inline.h>
@@ -58,6 +58,8 @@
 static int	ahc_ioctl(struct scsipi_channel *channel, u_long cmd,
 			  void *addr, int flag, struct proc *p);
 
+static bool	ahc_pmf_suspend(device_t PMF_FN_PROTO);
+static bool	ahc_pmf_resume(device_t PMF_FN_PROTO);
 
 
 /*
@@ -124,11 +126,44 @@
 	if ((ahc->features & AHC_TWIN) && ahc->flags & AHC_RESET_BUS_B)
 		ahc_reset_channel(ahc, 'B', TRUE);
 
+	if (!pmf_device_register(ahc->sc_dev, ahc_pmf_suspend, ahc_pmf_resume))
+		aprint_error_dev(ahc->sc_dev,
+		    "couldn't establish power handler\n");
+
 	ahc_unlock(ahc, &s);
 	return (1);
 }
 
 /*
+ * XXX we should call the real suspend and resume functions here
+ * but for some reason ahc_suspend() panics on shutdown
+ */
+
+static bool
+ahc_pmf_suspend(device_t dev PMF_FN_ARGS)
+{
+	struct ahc_softc *sc = device_private(dev);
+#if 0
+	return (ahc_suspend(sc) == 0);
+#else
+	ahc_shutdown(sc);
+	return true;
+#endif
+}
+
+static bool
+ahc_pmf_resume(device_t dev PMF_FN_ARGS)
+{
+#if 0
+	struct ahc_softc *sc = device_private(dev);
+
+	return (ahc_resume(sc) == 0);
+#else
+	return true;
+#endif
+}
+
+/*
  * Catch an interrupt from the adapter
  */
 void

Index: src/sys/dev/pci/ahc_pci.c
diff -u src/sys/dev/pci/ahc_pci.c:1.66 src/sys/dev/pci/ahc_pci.c:1.67
--- src/sys/dev/pci/ahc_pci.c:1.66	Wed May  6 09:25:14 2009
+++ src/sys/dev/pci/ahc_pci.c	Wed Sep  2 11:10:37 2009
@@ -39,7 +39,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: ahc_pci.c,v 1.66 2009/05/06 09:25:14 cegger Exp $
+ * $Id: ahc_pci.c,v 1.67 2009/09/02 11:10:37 tsutsui Exp $
  *
  * //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#57 $
  *
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahc_pci.c,v 1.66 2009/05/06 09:25:14 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahc_pci.c,v 1.67 2009/09/02 11:10:37 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -709,9 +709,6 @@
 
 static void ahc_pci_intr(struct ahc_softc *);
 
-static bool ahc_pci_suspend(device_t PMF_FN_PROTO);
-static bool ahc_pci_resume(device_t PMF_FN_PROTO);
-
 static const struct ahc_pci_identity *
 ahc_find_pci_device(pcireg_t id, pcireg_t subid, u_int func)
 {
@@ -1102,7 +1099,6 @@
 	if (ahc_init(ahc))
 		goto error_out;
 
-	pmf_device_register(self, ahc_pci_suspend, ahc_pci_resume);
 	ahc_attach(ahc);
 
 	return;
@@ -1112,35 +1108,6 @@
 	return;
 }
 
-/*
- * XXX we should call the real suspend and resume functions here
- * but for some reason ahc_suspend() panics on shutdown
- */
-
-static bool
-ahc_pci_suspend(device_t dev PMF_FN_ARGS)
-{
-	struct ahc_softc *sc = device_private(dev);
-#if 0
-	return (ahc_suspend(sc) == 0);
-#else
-	ahc_shutdown(sc);
-	return true;
-#endif
-}
-
-static bool
-ahc_pci_resume(device_t dev PMF_FN_ARGS)
-{
-#if 0
-	struct ahc_softc *sc = device_private(dev);
-
-	return (ahc_resume(sc) == 0);
-#else
-	return true;
-#endif
-}
-
 CFATTACH_DECL_NEW(ahc_pci, sizeof(struct ahc_softc),
     ahc_pci_probe, ahc_pci_attach, NULL, NULL);
 

Reply via email to