Module Name:    src
Committed By:   tsutsui
Date:           Sat Sep  5 14:13:50 UTC 2009

Modified Files:
        src/sys/dev/pci: if_an_pci.c if_ath_pci.c if_fxp_pci.c if_gem_pci.c
            if_rtk_pci.c if_rtw_pci.c if_wi_pci.c

Log Message:
Invert logic around nested pmf(9) registrations for readability.

XXX: should these pmf(9) calls be moved into MI attach functions
XXX: using function pointers for suspend and resume passed via softc?


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/pci/if_an_pci.c
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/pci/if_ath_pci.c
cvs rdiff -u -r1.69 -r1.70 src/sys/dev/pci/if_fxp_pci.c
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/pci/if_gem_pci.c
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/pci/if_rtk_pci.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pci/if_rtw_pci.c
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/pci/if_wi_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/pci/if_an_pci.c
diff -u src/sys/dev/pci/if_an_pci.c:1.29 src/sys/dev/pci/if_an_pci.c:1.30
--- src/sys/dev/pci/if_an_pci.c:1.29	Wed May  6 10:34:32 2009
+++ src/sys/dev/pci/if_an_pci.c	Sat Sep  5 14:13:50 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_an_pci.c,v 1.29 2009/05/06 10:34:32 cegger Exp $	*/
+/*	$NetBSD: if_an_pci.c,v 1.30 2009/09/05 14:13:50 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_an_pci.c,v 1.29 2009/05/06 10:34:32 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_an_pci.c,v 1.30 2009/09/05 14:13:50 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -168,8 +168,8 @@
 		bus_space_unmap(sc->sc_iot, sc->sc_ioh, iosize);
 	}
 
-	if (!pmf_device_register(self, NULL, NULL))
-		aprint_error_dev(self, "couldn't establish power handler\n");
-	else
+	if (pmf_device_register(self, NULL, NULL))
 		pmf_class_network_register(self, &sc->sc_if);
+	else
+		aprint_error_dev(self, "couldn't establish power handler\n");
 }

Index: src/sys/dev/pci/if_ath_pci.c
diff -u src/sys/dev/pci/if_ath_pci.c:1.33 src/sys/dev/pci/if_ath_pci.c:1.34
--- src/sys/dev/pci/if_ath_pci.c:1.33	Wed May  6 09:25:15 2009
+++ src/sys/dev/pci/if_ath_pci.c	Sat Sep  5 14:13:50 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ath_pci.c,v 1.33 2009/05/06 09:25:15 cegger Exp $	*/
+/*	$NetBSD: if_ath_pci.c,v 1.34 2009/09/05 14:13:50 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -41,7 +41,7 @@
 __FBSDID("$FreeBSD: src/sys/dev/ath/if_ath_pci.c,v 1.11 2005/01/18 18:08:16 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: if_ath_pci.c,v 1.33 2009/05/06 09:25:15 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ath_pci.c,v 1.34 2009/09/05 14:13:50 tsutsui Exp $");
 #endif
 
 /*
@@ -260,12 +260,11 @@
 	if (ath_attach(PCI_PRODUCT(pa->pa_id), sc) != 0)
 		goto bad3;
 
-	if (!pmf_device_register(self, ath_pci_suspend, ath_pci_resume))
-		aprint_error_dev(self, "couldn't establish power handler\n");
-	else {
+	if (pmf_device_register(self, ath_pci_suspend, ath_pci_resume)) {
 		pmf_class_network_register(self, &sc->sc_if);
 		pmf_device_suspend_self(self);
-	}
+	} else
+		aprint_error_dev(self, "couldn't establish power handler\n");
 	return;
 bad3:
 	ATH_LOCK_DESTROY(sc);

Index: src/sys/dev/pci/if_fxp_pci.c
diff -u src/sys/dev/pci/if_fxp_pci.c:1.69 src/sys/dev/pci/if_fxp_pci.c:1.70
--- src/sys/dev/pci/if_fxp_pci.c:1.69	Fri Apr 17 15:37:43 2009
+++ src/sys/dev/pci/if_fxp_pci.c	Sat Sep  5 14:13:50 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_fxp_pci.c,v 1.69 2009/04/17 15:37:43 tsutsui Exp $	*/
+/*	$NetBSD: if_fxp_pci.c,v 1.70 2009/09/05 14:13:50 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_fxp_pci.c,v 1.69 2009/04/17 15:37:43 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_fxp_pci.c,v 1.70 2009/09/05 14:13:50 tsutsui Exp $");
 
 #include "rnd.h"
 
@@ -482,10 +482,10 @@
 		fxp_disable(sc);
 
 	/* Add a suspend hook to restore PCI config state */
-	if (!pmf_device_register(self, NULL, fxp_pci_resume))
-		aprint_error_dev(self, "couldn't establish power handler\n");
-	else
+	if (pmf_device_register(self, NULL, fxp_pci_resume))
 		pmf_class_network_register(self, &sc->sc_ethercom.ec_if);
+	else
+		aprint_error_dev(self, "couldn't establish power handler\n");
 }
 
 static int

Index: src/sys/dev/pci/if_gem_pci.c
diff -u src/sys/dev/pci/if_gem_pci.c:1.36 src/sys/dev/pci/if_gem_pci.c:1.37
--- src/sys/dev/pci/if_gem_pci.c:1.36	Mon Jul 27 18:10:53 2009
+++ src/sys/dev/pci/if_gem_pci.c	Sat Sep  5 14:13:50 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_gem_pci.c,v 1.36 2009/07/27 18:10:53 dyoung Exp $ */
+/*	$NetBSD: if_gem_pci.c,v 1.37 2009/09/05 14:13:50 tsutsui Exp $ */
 
 /*
  *
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gem_pci.c,v 1.36 2009/07/27 18:10:53 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gem_pci.c,v 1.37 2009/09/05 14:13:50 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -399,12 +399,12 @@
 	/* Finish off the attach. */
 	gem_attach(sc, enaddr);
 
-	if (!pmf_device_register1(sc->sc_dev, gem_pci_suspend, gem_pci_resume,
-	                          gem_shutdown)) {
+	if (pmf_device_register1(sc->sc_dev,
+	    gem_pci_suspend, gem_pci_resume, gem_shutdown))
+		pmf_class_network_register(sc->sc_dev, &sc->sc_ethercom.ec_if);
+	else
 		aprint_error_dev(sc->sc_dev,
 		    "could not establish power handlers\n");
-	} else
-		pmf_class_network_register(sc->sc_dev, &sc->sc_ethercom.ec_if);
 }
 
 static bool

Index: src/sys/dev/pci/if_rtk_pci.c
diff -u src/sys/dev/pci/if_rtk_pci.c:1.38 src/sys/dev/pci/if_rtk_pci.c:1.39
--- src/sys/dev/pci/if_rtk_pci.c:1.38	Wed May  6 09:25:16 2009
+++ src/sys/dev/pci/if_rtk_pci.c	Sat Sep  5 14:13:50 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_rtk_pci.c,v 1.38 2009/05/06 09:25:16 cegger Exp $	*/
+/*	$NetBSD: if_rtk_pci.c,v 1.39 2009/09/05 14:13:50 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998
@@ -47,7 +47,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_rtk_pci.c,v 1.38 2009/05/06 09:25:16 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_rtk_pci.c,v 1.39 2009/09/05 14:13:50 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -225,10 +225,10 @@
 	sc->sc_dmat = pa->pa_dmat;
 	sc->sc_flags |= RTK_ENABLED;
 
-	if (!pmf_device_register(self, NULL, NULL))
-		aprint_error_dev(self, "couldn't establish power handler\n");
-	else
+	if (pmf_device_register(self, NULL, NULL))
 		pmf_class_network_register(self, &sc->ethercom.ec_if);
+	else
+		aprint_error_dev(self, "couldn't establish power handler\n");
 
 	rtk_attach(sc);
 }

Index: src/sys/dev/pci/if_rtw_pci.c
diff -u src/sys/dev/pci/if_rtw_pci.c:1.13 src/sys/dev/pci/if_rtw_pci.c:1.14
--- src/sys/dev/pci/if_rtw_pci.c:1.13	Wed May  6 09:25:16 2009
+++ src/sys/dev/pci/if_rtw_pci.c	Sat Sep  5 14:13:50 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_rtw_pci.c,v 1.13 2009/05/06 09:25:16 cegger Exp $	*/
+/*	$NetBSD: if_rtw_pci.c,v 1.14 2009/09/05 14:13:50 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_rtw_pci.c,v 1.13 2009/05/06 09:25:16 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_rtw_pci.c,v 1.14 2009/09/05 14:13:50 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -251,17 +251,15 @@
 	 */
 	rtw_attach(sc);
 
-	if (!pmf_device_register(sc->sc_dev, rtw_pci_suspend,
-	                         rtw_pci_resume)) {
-		aprint_error_dev(sc->sc_dev,
-		    "couldn't establish power handler\n");
-	} else {
+	if (pmf_device_register(sc->sc_dev, rtw_pci_suspend, rtw_pci_resume)) {
 		pmf_class_network_register(self, &sc->sc_if);
 		/*
 		 * Power down the socket.
 		 */
 		pmf_device_suspend_self(self);
-	}
+	} else
+		aprint_error_dev(sc->sc_dev,
+		    "couldn't establish power handler\n");
 }
 
 static int

Index: src/sys/dev/pci/if_wi_pci.c
diff -u src/sys/dev/pci/if_wi_pci.c:1.48 src/sys/dev/pci/if_wi_pci.c:1.49
--- src/sys/dev/pci/if_wi_pci.c:1.48	Tue May 12 08:23:01 2009
+++ src/sys/dev/pci/if_wi_pci.c	Sat Sep  5 14:13:50 2009
@@ -1,4 +1,4 @@
-/*      $NetBSD: if_wi_pci.c,v 1.48 2009/05/12 08:23:01 cegger Exp $  */
+/*      $NetBSD: if_wi_pci.c,v 1.49 2009/09/05 14:13:50 tsutsui Exp $  */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wi_pci.c,v 1.48 2009/05/12 08:23:01 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wi_pci.c,v 1.49 2009/09/05 14:13:50 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -373,8 +373,8 @@
 	if (!wpp->wpp_chip)
 		sc->sc_reset = wi_pci_reset;
 
-	if (!pmf_device_register(self, NULL, NULL))
-		aprint_error_dev(self, "couldn't establish power handler\n");
-	else
+	if (pmf_device_register(self, NULL, NULL))
 		pmf_class_network_register(self, &sc->sc_if);
+	else
+		aprint_error_dev(self, "couldn't establish power handler\n");
 }

Reply via email to