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?
This commit is contained in:
tsutsui 2009-09-05 14:13:50 +00:00
parent 64cbab9fdb
commit 9444aeea7a
7 changed files with 37 additions and 40 deletions

View File

@ -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 @@ an_pci_attach(device_t parent, device_t self, void *aux)
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");
}

View File

@ -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 @@ ath_pci_attach(device_t parent, device_t self, void *aux)
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);

View File

@ -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_pci_attach(device_t parent, device_t self, void *aux)
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

View File

@ -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 @@ gem_pci_attach(device_t parent, device_t self, void *aux)
/* 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

View File

@ -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 @@ rtk_pci_attach(device_t parent, device_t self, void *aux)
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);
}

View File

@ -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_pci_attach(device_t parent, device_t self, void *aux)
*/
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

View File

@ -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 @@ wi_pci_attach(device_t parent, device_t self, void *aux)
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");
}