From 443ca83eb31088cd95697f0322e7497eff777fd5 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sun, 29 Aug 2010 16:47:01 +0000 Subject: Massage the powerhook functions into activate functions, and then call them from the powerhook. Fix a few quibbles about the things done for the IFF_RUNNING and IFF_UP cases ok kettenis --- sys/dev/ic/rtw.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'sys/dev/ic/rtw.c') 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); -- cgit v1.2.3