Module Name:    src
Committed By:   martin
Date:           Sat Apr  6 14:57:38 UTC 2013

Modified Files:
        src/sys/dev/ic: arn5008.c arn9003.c athn.c

Log Message:
Debounce the "wlan button pressed" event via pmf PMFE_RADIO_OFF so we
can run the pmf stuff in thread context.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/arn5008.c src/sys/dev/ic/arn9003.c \
    src/sys/dev/ic/athn.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/arn5008.c
diff -u src/sys/dev/ic/arn5008.c:1.2 src/sys/dev/ic/arn5008.c:1.3
--- src/sys/dev/ic/arn5008.c:1.2	Wed Apr  3 14:20:02 2013
+++ src/sys/dev/ic/arn5008.c	Sat Apr  6 14:57:38 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: arn5008.c,v 1.2 2013/04/03 14:20:02 christos Exp $	*/
+/*	$NetBSD: arn5008.c,v 1.3 2013/04/06 14:57:38 martin Exp $	*/
 /*	$OpenBSD: ar5008.c,v 1.21 2012/08/25 12:14:31 kettenis Exp $	*/
 
 /*-
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arn5008.c,v 1.2 2013/04/03 14:20:02 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arn5008.c,v 1.3 2013/04/06 14:57:38 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/sockio.h>
@@ -1256,13 +1256,7 @@ ar5008_intr(struct athn_softc *sc)
 
 		if ((sc->sc_flags & ATHN_FLAG_RFSILENT) &&
 		    (sync & AR_INTR_SYNC_GPIO_PIN(sc->sc_rfsilent_pin))) {
-			struct ifnet *ifp = &sc->sc_if;
-
-			printf("%s: radio switch turned off\n",
-			    device_xname(sc->sc_dev));
-			/* Turn the interface down. */
-			ifp->if_flags &= ~IFF_UP;
-			athn_stop(ifp, 1);
+			pmf_event_inject(sc->sc_dev, PMFE_RADIO_OFF);
 			return 1;
 		}
 
Index: src/sys/dev/ic/arn9003.c
diff -u src/sys/dev/ic/arn9003.c:1.2 src/sys/dev/ic/arn9003.c:1.3
--- src/sys/dev/ic/arn9003.c:1.2	Wed Apr  3 14:20:02 2013
+++ src/sys/dev/ic/arn9003.c	Sat Apr  6 14:57:38 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: arn9003.c,v 1.2 2013/04/03 14:20:02 christos Exp $	*/
+/*	$NetBSD: arn9003.c,v 1.3 2013/04/06 14:57:38 martin Exp $	*/
 /*	$OpenBSD: ar9003.c,v 1.25 2012/10/20 09:53:32 stsp Exp $	*/
 
 /*-
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arn9003.c,v 1.2 2013/04/03 14:20:02 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arn9003.c,v 1.3 2013/04/06 14:57:38 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/sockio.h>
@@ -1406,13 +1406,7 @@ ar9003_intr(struct athn_softc *sc)
 
 		if ((sc->sc_flags & ATHN_FLAG_RFSILENT) &&
 		    (sync & AR_INTR_SYNC_GPIO_PIN(sc->sc_rfsilent_pin))) {
-			struct ifnet *ifp = &sc->sc_if;
-
-			printf("%s: radio switch turned off\n",
-			    device_xname(sc->sc_dev));
-			/* Turn the interface down. */
-			ifp->if_flags &= ~IFF_UP;
-			athn_stop(ifp, 1);
+			pmf_event_inject(sc->sc_dev, PMFE_RADIO_OFF);
 			return 1;
 		}
 
Index: src/sys/dev/ic/athn.c
diff -u src/sys/dev/ic/athn.c:1.2 src/sys/dev/ic/athn.c:1.3
--- src/sys/dev/ic/athn.c:1.2	Fri Apr  5 19:14:31 2013
+++ src/sys/dev/ic/athn.c	Sat Apr  6 14:57:38 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: athn.c,v 1.2 2013/04/05 19:14:31 martin Exp $	*/
+/*	$NetBSD: athn.c,v 1.3 2013/04/06 14:57:38 martin Exp $	*/
 /*	$OpenBSD: athn.c,v 1.75 2013/01/14 09:50:31 jsing Exp $	*/
 
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: athn.c,v 1.2 2013/04/05 19:14:31 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: athn.c,v 1.3 2013/04/06 14:57:38 martin Exp $");
 
 #ifndef _MODULE
 #include "athn_usb.h"		/* for NATHN_USB */
@@ -136,6 +136,9 @@ Static void	athn_ani_restart(struct athn
 Static void	athn_set_multi(struct athn_softc *);
 #endif /* notyet */
 
+Static void	athn_pmf_wlan_off(device_t self);
+
+
 PUBLIC int
 athn_attach(struct athn_softc *sc)
 {
@@ -179,6 +182,8 @@ athn_attach(struct athn_softc *sc)
 	}
 
 	pmf_self_suspensor_init(sc->sc_dev, &sc->sc_suspensor, &sc->sc_qual);
+	pmf_event_register(sc->sc_dev, PMFE_RADIO_OFF, athn_pmf_wlan_off,
+	    false);
 
 	/* We can put the chip in sleep state now. */
 	athn_set_power_sleep(sc);
@@ -230,7 +235,7 @@ athn_attach(struct athn_softc *sc)
 	    ((sc->sc_rxchainmask >> 0) & 1);
 
 	if (AR_SINGLE_CHIP(sc)) {
-		aprint_normal("%s\n", athn_get_mac_name(sc));
+		aprint_normal(": Atheros %s\n", athn_get_mac_name(sc));
 		aprint_verbose_dev(sc->sc_dev,
 		    "rev %d (%dT%dR), ROM rev %d, address %s\n",
 		    sc->sc_mac_rev,
@@ -238,7 +243,7 @@ athn_attach(struct athn_softc *sc)
 		    ether_sprintf(ic->ic_myaddr));
 	}
 	else {
-		aprint_normal("%s, RF %s\n", athn_get_mac_name(sc),
+		aprint_normal(": Atheros %s, RF %s\n", athn_get_mac_name(sc),
 		    athn_get_rf_name(sc));
 		aprint_verbose_dev(sc->sc_dev,
 		    "rev %d (%dT%dR), ROM rev %d, address %s\n",
@@ -2952,6 +2957,17 @@ athn_stop(struct ifnet *ifp, int disable
 		pmf_device_recursive_suspend(sc->sc_dev, &sc->sc_qual);
 }
 
+Static void
+athn_pmf_wlan_off(device_t self)
+{
+	struct athn_softc *sc = device_private(self);
+	struct ifnet *ifp = &sc->sc_if;
+
+	/* Turn the interface down. */
+	ifp->if_flags &= ~IFF_UP;
+	athn_stop(ifp, 1);
+}
+
 PUBLIC void
 athn_suspend(struct athn_softc *sc)
 {

Reply via email to