summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/ic/atw.c53
-rw-r--r--sys/dev/ic/atwvar.h8
-rw-r--r--sys/dev/ic/rtw.c39
-rw-r--r--sys/dev/ic/rtwvar.h4
-rw-r--r--sys/dev/pci/if_atw_pci.c5
-rw-r--r--sys/dev/pci/if_rtw_pci.c4
6 files changed, 64 insertions, 49 deletions
diff --git a/sys/dev/ic/atw.c b/sys/dev/ic/atw.c
index 71a1e00e994..6cf9487474f 100644
--- a/sys/dev/ic/atw.c
+++ b/sys/dev/ic/atw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atw.c,v 1.70 2010/08/27 04:09:18 deraadt Exp $ */
+/* $OpenBSD: atw.c,v 1.71 2010/08/29 16:46:58 deraadt Exp $ */
/* $NetBSD: atw.c,v 1.69 2004/07/23 07:07:55 dyoung Exp $ */
/*-
@@ -846,7 +846,7 @@ atw_attach(struct atw_softc *sc)
* Add a suspend hook to make sure we come back up after a
* resume.
*/
- sc->sc_powerhook = powerhook_establish(atw_power, sc);
+ sc->sc_powerhook = powerhook_establish(atw_powerhook, sc);
if (sc->sc_powerhook == NULL)
printf("%s: WARNING: unable to establish power hook\n",
sc->sc_dev.dv_xname);
@@ -3978,36 +3978,43 @@ atw_start(struct ifnet *ifp)
}
}
-/*
- * atw_power:
- *
- * Power management (suspend/resume) hook.
- */
-void
-atw_power(int why, void *arg)
+int
+atw_activate(struct device *self, int act)
{
- struct atw_softc *sc = arg;
+ struct atw_softc *sc = (struct atw_softc *)self;
struct ifnet *ifp = &sc->sc_ic.ic_if;
- int s;
- DPRINTF(sc, ("%s: atw_power(%d,)\n", sc->sc_dev.dv_xname, why));
-
- s = splnet();
- switch (why) {
+ switch (act) {
case PWR_SUSPEND:
- atw_stop(ifp, 1);
+ if (ifp->if_flags & IFF_RUNNING)
+ atw_stop(ifp, 1);
if (sc->sc_power != NULL)
- (*sc->sc_power)(sc, why);
+ (*sc->sc_power)(sc, act);
break;
case PWR_RESUME:
- if (ifp->if_flags & IFF_UP) {
- if (sc->sc_power != NULL)
- (*sc->sc_power)(sc, why);
- atw_init(ifp);
- }
+ workq_queue_task(NULL, &sc->sc_resume_wqt, 0,
+ atw_resume, sc, NULL);
break;
}
- splx(s);
+ return 0;
+}
+
+void
+atw_resume(void *arg1, void *arg2)
+{
+ struct atw_softc *sc = (struct atw_softc *)arg1;
+ struct ifnet *ifp = &sc->sc_ic.ic_if;
+
+ if (sc->sc_power != NULL)
+ (*sc->sc_power)(sc, DVACT_RESUME);
+ if (ifp->if_flags & IFF_UP)
+ atw_init(ifp);
+}
+
+void
+atw_powerhook(int why, void *arg)
+{
+ atw_activate(arg, why);
}
/*
diff --git a/sys/dev/ic/atwvar.h b/sys/dev/ic/atwvar.h
index 0f7698db1b5..2469de01355 100644
--- a/sys/dev/ic/atwvar.h
+++ b/sys/dev/ic/atwvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: atwvar.h,v 1.21 2009/10/13 19:33:16 pirofti Exp $ */
+/* $OpenBSD: atwvar.h,v 1.22 2010/08/29 16:46:58 deraadt Exp $ */
/* $NetBSD: atwvar.h,v 1.13 2004/07/23 07:07:55 dyoung Exp $ */
/*
@@ -35,6 +35,7 @@
#include <sys/queue.h>
#include <sys/time.h>
#include <sys/timeout.h>
+#include <sys/workq.h>
/*
* Some misc. statics, useful for debugging.
@@ -278,6 +279,8 @@ struct atw_softc {
struct atw_tx_radiotap_header tap;
u_int8_t pad[64];
} sc_txtapu;
+
+ struct workq_task sc_resume_wqt;
};
#define sc_rxtap sc_rxtapu.tap
@@ -438,6 +441,7 @@ int atw_detach(struct atw_softc *);
int atw_activate(struct device *, int);
int atw_intr(void *arg);
int atw_enable(struct atw_softc *);
-void atw_power(int, void *);
+void atw_powerhook(int, void *);
+void atw_resume(void *, void *);
#endif /* _DEV_IC_ATWVAR_H_ */
diff --git a/sys/dev/ic/rtw.c b/sys/dev/ic/rtw.c
index 6b4961366c0..a94ec7e9f5c 100644
--- a/sys/dev/ic/rtw.c
+++ b/sys/dev/ic/rtw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtw.c,v 1.79 2010/08/27 04:09:19 deraadt Exp $ */
+/* $OpenBSD: rtw.c,v 1.80 2010/08/29 16:46:58 deraadt Exp $ */
/* $NetBSD: rtw.c,v 1.29 2004/12/27 19:49:16 dyoung Exp $ */
/*-
@@ -3593,32 +3593,35 @@ rtw_media_status(struct ifnet *ifp, struct ifmediareq *imr)
ieee80211_media_status(ifp, imr);
}
-void
-rtw_power(int why, void *arg)
+int
+rtw_activate(struct device *self, int act)
{
- struct rtw_softc *sc = arg;
+ struct rtw_softc *sc = (struct rtw_softc *)self;
struct ifnet *ifp = &sc->sc_ic.ic_if;
- int s;
- DPRINTF(sc, RTW_DEBUG_PWR,
- ("%s: rtw_power(%d,)\n", sc->sc_dev.dv_xname, why));
-
- s = splnet();
- switch (why) {
- case PWR_SUSPEND:
- rtw_stop(ifp, 1);
- if (sc->sc_power != NULL)
- (*sc->sc_power)(sc, why);
+ switch (act) {
+ case DVACT_SUSPEND:
+ if (ifp->if_flags & IFF_RUNNING) {
+ rtw_stop(ifp, 1);
+ if (sc->sc_power != NULL)
+ (*sc->sc_power)(sc, act);
+ }
break;
- case PWR_RESUME:
+ case DVACT_RESUME:
if (ifp->if_flags & IFF_UP) {
if (sc->sc_power != NULL)
- (*sc->sc_power)(sc, why);
+ (*sc->sc_power)(sc, act);
rtw_init(ifp);
}
break;
}
- splx(s);
+ return 0;
+}
+
+void
+rtw_powerhook(int why, void *arg)
+{
+ rtw_activate(arg, why);
}
void
@@ -3629,7 +3632,7 @@ rtw_establish_hooks(struct rtw_hooks *hooks, const char *dvname,
* Add a suspend hook to make sure we come back up after a
* resume.
*/
- hooks->rh_power = powerhook_establish(rtw_power, arg);
+ hooks->rh_power = powerhook_establish(rtw_powerhook, arg);
if (hooks->rh_power == NULL)
printf("%s: WARNING: unable to establish power hook\n",
dvname);
diff --git a/sys/dev/ic/rtwvar.h b/sys/dev/ic/rtwvar.h
index 7c59f731ec8..b3ed4fdb698 100644
--- a/sys/dev/ic/rtwvar.h
+++ b/sys/dev/ic/rtwvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtwvar.h,v 1.28 2009/10/13 19:33:16 pirofti Exp $ */
+/* $OpenBSD: rtwvar.h,v 1.29 2010/08/29 16:46:58 deraadt Exp $ */
/* $NetBSD: rtwvar.h,v 1.10 2004/12/26 22:37:57 mycroft Exp $ */
/*-
@@ -453,7 +453,7 @@ void rtw_disable(struct rtw_softc *);
int rtw_enable(struct rtw_softc *);
int rtw_activate(struct device *, int);
-void rtw_power(int, void *);
+void rtw_powerhook(int, void *);
void rtw_shutdown(void *);
const char *rtw_pwrstate_string(enum rtw_pwrstate);
diff --git a/sys/dev/pci/if_atw_pci.c b/sys/dev/pci/if_atw_pci.c
index 1a3f1e4279f..b1056206c6c 100644
--- a/sys/dev/pci/if_atw_pci.c
+++ b/sys/dev/pci/if_atw_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_atw_pci.c,v 1.12 2009/06/02 15:13:58 jsg Exp $ */
+/* $OpenBSD: if_atw_pci.c,v 1.13 2010/08/29 16:47:00 deraadt Exp $ */
/* $NetBSD: if_atw_pci.c,v 1.7 2004/07/23 07:07:55 dyoung Exp $ */
/*-
@@ -93,7 +93,8 @@ void atw_pci_attach(struct device *, struct device *, void *);
int atw_pci_detach(struct device *, int);
struct cfattach atw_pci_ca = {
- sizeof (struct atw_softc), atw_pci_match, atw_pci_attach, atw_pci_detach
+ sizeof (struct atw_softc), atw_pci_match, atw_pci_attach, atw_pci_detach,
+ atw_activate
};
const struct pci_matchid atw_pci_devices[] = {
diff --git a/sys/dev/pci/if_rtw_pci.c b/sys/dev/pci/if_rtw_pci.c
index 0e697394719..2b316d6c829 100644
--- a/sys/dev/pci/if_rtw_pci.c
+++ b/sys/dev/pci/if_rtw_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_rtw_pci.c,v 1.13 2009/06/26 20:40:12 deraadt Exp $ */
+/* $OpenBSD: if_rtw_pci.c,v 1.14 2010/08/29 16:47:00 deraadt Exp $ */
/* $NetBSD: if_rtw_pci.c,v 1.1 2004/09/26 02:33:36 dyoung Exp $ */
/*-
@@ -100,7 +100,7 @@ void rtw_pci_attach(struct device *, struct device *, void *);
struct cfattach rtw_pci_ca = {
sizeof (struct rtw_pci_softc), rtw_pci_match, rtw_pci_attach,
- rtw_pci_detach
+ rtw_pci_detach, rtw_activate
};
const struct pci_matchid rtw_pci_products[] = {