From edeaa5dd16dec43f4dad72e67d34e7e08b032f5e Mon Sep 17 00:00:00 2001 From: tsutsui Date: Sat, 5 Sep 2009 14:44:59 +0000 Subject: [PATCH] Invert logic around nested pmf(9) registrations for readability. --- sys/dev/cardbus/if_ath_cardbus.c | 12 ++++++------ sys/dev/cardbus/if_fxp_cardbus.c | 10 +++++----- sys/dev/cardbus/if_rtk_cardbus.c | 10 +++++----- sys/dev/cardbus/if_rtw_cardbus.c | 12 ++++++------ sys/dev/pcmcia/if_an_pcmcia.c | 10 +++++----- sys/dev/pcmcia/if_ne_pcmcia.c | 11 +++++------ sys/dev/pcmcia/if_ray.c | 10 +++++----- sys/dev/pcmcia/if_wi_pcmcia.c | 10 +++++----- 8 files changed, 42 insertions(+), 43 deletions(-) diff --git a/sys/dev/cardbus/if_ath_cardbus.c b/sys/dev/cardbus/if_ath_cardbus.c index a43e68c2f18f..b892b63de941 100644 --- a/sys/dev/cardbus/if_ath_cardbus.c +++ b/sys/dev/cardbus/if_ath_cardbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ath_cardbus.c,v 1.33 2009/05/12 12:11:17 cegger Exp $ */ +/* $NetBSD: if_ath_cardbus.c,v 1.34 2009/09/05 14:50:10 tsutsui Exp $ */ /* * Copyright (c) 2003 * Ichiro FUKUHARA . @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ath_cardbus.c,v 1.33 2009/05/12 12:11:17 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ath_cardbus.c,v 1.34 2009/09/05 14:50:10 tsutsui Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -215,12 +215,12 @@ ath_cardbus_attach(device_t parent, device_t self, void *aux) if (ath_attach(PCI_PRODUCT(ca->ca_id), sc) != 0) return; - if (!pmf_device_register(self, ath_cardbus_suspend, ath_cardbus_resume)) - aprint_error_dev(self, "couldn't establish power handler\n"); - else { + if (pmf_device_register(self, + ath_cardbus_suspend, ath_cardbus_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"); } int diff --git a/sys/dev/cardbus/if_fxp_cardbus.c b/sys/dev/cardbus/if_fxp_cardbus.c index d54d339c43c2..694cba2b67fc 100644 --- a/sys/dev/cardbus/if_fxp_cardbus.c +++ b/sys/dev/cardbus/if_fxp_cardbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_fxp_cardbus.c,v 1.39 2009/05/12 14:17:31 cegger Exp $ */ +/* $NetBSD: if_fxp_cardbus.c,v 1.40 2009/09/05 14:50:10 tsutsui Exp $ */ /* * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_fxp_cardbus.c,v 1.39 2009/05/12 14:17:31 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_fxp_cardbus.c,v 1.40 2009/09/05 14:50:10 tsutsui Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -183,10 +183,10 @@ fxp_cardbus_attach(device_t parent, device_t self, fxp_attach(sc); fxp_disable(sc); - 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_ethercom.ec_if); + else + aprint_error_dev(self, "couldn't establish power handler\n"); } static void diff --git a/sys/dev/cardbus/if_rtk_cardbus.c b/sys/dev/cardbus/if_rtk_cardbus.c index d25ca23c280b..254f16827136 100644 --- a/sys/dev/cardbus/if_rtk_cardbus.c +++ b/sys/dev/cardbus/if_rtk_cardbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_rtk_cardbus.c,v 1.37 2008/06/24 19:44:52 drochner Exp $ */ +/* $NetBSD: if_rtk_cardbus.c,v 1.38 2009/09/05 14:50:10 tsutsui Exp $ */ /* * Copyright (c) 2000 Masanori Kanaoka @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_rtk_cardbus.c,v 1.37 2008/06/24 19:44:52 drochner Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_rtk_cardbus.c,v 1.38 2009/09/05 14:50:10 tsutsui Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -246,10 +246,10 @@ rtk_cardbus_attach(device_t parent, device_t self, void *aux) rtk_attach(sc); - 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"); /* * Power down the socket. diff --git a/sys/dev/cardbus/if_rtw_cardbus.c b/sys/dev/cardbus/if_rtw_cardbus.c index 47d7df653f5e..fa5426429c86 100644 --- a/sys/dev/cardbus/if_rtw_cardbus.c +++ b/sys/dev/cardbus/if_rtw_cardbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_rtw_cardbus.c,v 1.29 2009/05/12 12:11:17 cegger Exp $ */ +/* $NetBSD: if_rtw_cardbus.c,v 1.30 2009/09/05 14:50:10 tsutsui Exp $ */ /*- * Copyright (c) 2004, 2005 David Young. All rights reserved. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_rtw_cardbus.c,v 1.29 2009/05/12 12:11:17 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_rtw_cardbus.c,v 1.30 2009/09/05 14:50:10 tsutsui Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -296,15 +296,15 @@ rtw_cardbus_attach(device_t parent, device_t self, void *aux) RTW_WRITE(regs, RTW_FEMR, 0); RTW_WRITE(regs, RTW_FER, RTW_READ(regs, RTW_FER)); - if (!pmf_device_register(self, rtw_cardbus_suspend, rtw_cardbus_resume)) - aprint_error_dev(self, "couldn't establish power handler\n"); - else { + if (pmf_device_register(self, + rtw_cardbus_suspend, rtw_cardbus_resume)) { pmf_class_network_register(self, &sc->sc_if); /* * Power down the socket. */ pmf_device_suspend_self(self); - } + } else + aprint_error_dev(self, "couldn't establish power handler\n"); } int diff --git a/sys/dev/pcmcia/if_an_pcmcia.c b/sys/dev/pcmcia/if_an_pcmcia.c index fa731627d3e4..f7f52496a234 100644 --- a/sys/dev/pcmcia/if_an_pcmcia.c +++ b/sys/dev/pcmcia/if_an_pcmcia.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_an_pcmcia.c,v 1.39 2009/05/12 14:42:18 cegger Exp $ */ +/* $NetBSD: if_an_pcmcia.c,v 1.40 2009/09/05 14:44:59 tsutsui Exp $ */ /*- * Copyright (c) 2000, 2004 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_an_pcmcia.c,v 1.39 2009/05/12 14:42:18 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_an_pcmcia.c,v 1.40 2009/09/05 14:44:59 tsutsui Exp $"); #include #include @@ -155,10 +155,10 @@ an_pcmcia_attach(struct device *parent, device_t self, goto fail2; } - 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"); an_pcmcia_disable(sc); sc->sc_enabled = 0; diff --git a/sys/dev/pcmcia/if_ne_pcmcia.c b/sys/dev/pcmcia/if_ne_pcmcia.c index 96317f15316a..65d1b8591d84 100644 --- a/sys/dev/pcmcia/if_ne_pcmcia.c +++ b/sys/dev/pcmcia/if_ne_pcmcia.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ne_pcmcia.c,v 1.156 2009/04/05 03:37:07 uwe Exp $ */ +/* $NetBSD: if_ne_pcmcia.c,v 1.157 2009/09/05 14:44:59 tsutsui Exp $ */ /* * Copyright (c) 1997 Marc Horowitz. All rights reserved. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ne_pcmcia.c,v 1.156 2009/04/05 03:37:07 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ne_pcmcia.c,v 1.157 2009/09/05 14:44:59 tsutsui Exp $"); #include #include @@ -741,13 +741,12 @@ found: "WARNING: unable to establish power hook\n"); /* pmf(9) power hooks */ - if (!pmf_device_register(self, ne2000_suspend, ne2000_resume)) - aprint_error_dev(self, "unable to establish power handler\n"); - else { + if (pmf_device_register(self, ne2000_suspend, ne2000_resume)) { #if 0 /* XXX: notyet: if_stop is NULL! */ pmf_class_network_register(self, &dsc->sc_ec.ec_if); #endif - } + } else + aprint_error_dev(self, "unable to establish power handler\n"); psc->sc_state = NE_PCMCIA_ATTACHED; ne_pcmcia_disable(dsc); diff --git a/sys/dev/pcmcia/if_ray.c b/sys/dev/pcmcia/if_ray.c index ecb6fb97181a..9ce4a3bc7162 100644 --- a/sys/dev/pcmcia/if_ray.c +++ b/sys/dev/pcmcia/if_ray.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ray.c,v 1.75 2009/05/12 14:42:18 cegger Exp $ */ +/* $NetBSD: if_ray.c,v 1.76 2009/09/05 14:44:59 tsutsui Exp $ */ /* * Copyright (c) 2000 Christian E. Hopps @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ray.c,v 1.75 2009/05/12 14:42:18 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ray.c,v 1.76 2009/09/05 14:44:59 tsutsui Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -602,10 +602,10 @@ ray_attach(device_t parent, device_t self, void *aux) else ifmedia_set(&sc->sc_media, IFM_INFRA); - 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, ifp); + else + aprint_error_dev(self, "couldn't establish power handler\n"); /* The attach is successful. */ sc->sc_attached = 1; diff --git a/sys/dev/pcmcia/if_wi_pcmcia.c b/sys/dev/pcmcia/if_wi_pcmcia.c index 6ceac7d506f8..5943f0110156 100644 --- a/sys/dev/pcmcia/if_wi_pcmcia.c +++ b/sys/dev/pcmcia/if_wi_pcmcia.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_wi_pcmcia.c,v 1.84 2009/05/12 14:42:18 cegger Exp $ */ +/* $NetBSD: if_wi_pcmcia.c,v 1.85 2009/09/05 14:44:59 tsutsui Exp $ */ /*- * Copyright (c) 2001, 2004 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wi_pcmcia.c,v 1.84 2009/05/12 14:42:18 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wi_pcmcia.c,v 1.85 2009/09/05 14:44:59 tsutsui Exp $"); #include #include @@ -376,10 +376,10 @@ wi_pcmcia_attach(struct device *parent, device_t self, goto fail2; } - 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"); wi_pcmcia_disable(sc); psc->sc_state = WI_PCMCIA_ATTACHED;