From 9444aeea7afb08c81663aa6eaf82e16388d7913a Mon Sep 17 00:00:00 2001 From: tsutsui Date: Sat, 5 Sep 2009 14:13:50 +0000 Subject: [PATCH] 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? --- sys/dev/pci/if_an_pci.c | 10 +++++----- sys/dev/pci/if_ath_pci.c | 11 +++++------ sys/dev/pci/if_fxp_pci.c | 10 +++++----- sys/dev/pci/if_gem_pci.c | 12 ++++++------ sys/dev/pci/if_rtk_pci.c | 10 +++++----- sys/dev/pci/if_rtw_pci.c | 14 ++++++-------- sys/dev/pci/if_wi_pci.c | 10 +++++----- 7 files changed, 37 insertions(+), 40 deletions(-) diff --git a/sys/dev/pci/if_an_pci.c b/sys/dev/pci/if_an_pci.c index aaae4bd17107..610a5b8872c1 100644 --- a/sys/dev/pci/if_an_pci.c +++ b/sys/dev/pci/if_an_pci.c @@ -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 -__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 #include @@ -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"); } diff --git a/sys/dev/pci/if_ath_pci.c b/sys/dev/pci/if_ath_pci.c index 0eeb0de12c5e..f6590f38ecfa 100644 --- a/sys/dev/pci/if_ath_pci.c +++ b/sys/dev/pci/if_ath_pci.c @@ -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); diff --git a/sys/dev/pci/if_fxp_pci.c b/sys/dev/pci/if_fxp_pci.c index 73eeb6794fc3..706575c8870d 100644 --- a/sys/dev/pci/if_fxp_pci.c +++ b/sys/dev/pci/if_fxp_pci.c @@ -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 -__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 diff --git a/sys/dev/pci/if_gem_pci.c b/sys/dev/pci/if_gem_pci.c index 08f0b326ce09..474646650ee1 100644 --- a/sys/dev/pci/if_gem_pci.c +++ b/sys/dev/pci/if_gem_pci.c @@ -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 -__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 #include @@ -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 diff --git a/sys/dev/pci/if_rtk_pci.c b/sys/dev/pci/if_rtk_pci.c index cfe48dd03047..b6edf6fbdaa5 100644 --- a/sys/dev/pci/if_rtk_pci.c +++ b/sys/dev/pci/if_rtk_pci.c @@ -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 -__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 #include @@ -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); } diff --git a/sys/dev/pci/if_rtw_pci.c b/sys/dev/pci/if_rtw_pci.c index 611e809df69d..786a5dd6513c 100644 --- a/sys/dev/pci/if_rtw_pci.c +++ b/sys/dev/pci/if_rtw_pci.c @@ -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 -__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 #include @@ -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 diff --git a/sys/dev/pci/if_wi_pci.c b/sys/dev/pci/if_wi_pci.c index 24e10ae97b02..491976d90b6a 100644 --- a/sys/dev/pci/if_wi_pci.c +++ b/sys/dev/pci/if_wi_pci.c @@ -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 -__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 #include @@ -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"); }