From: deraadt Date: Wed, 4 Aug 2010 16:29:42 +0000 (+0000) Subject: activate function for suspend/resume; tested by mcbride X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=fcf820801ec8aaa15248aa46ae33bddab359afb6;p=openbsd activate function for suspend/resume; tested by mcbride --- diff --git a/sys/dev/pci/if_wi_pci.c b/sys/dev/pci/if_wi_pci.c index fcf8408f929..48c3236b58e 100644 --- a/sys/dev/pci/if_wi_pci.c +++ b/sys/dev/pci/if_wi_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi_pci.c,v 1.44 2009/03/29 21:53:52 sthen Exp $ */ +/* $OpenBSD: if_wi_pci.c,v 1.45 2010/08/04 16:29:42 deraadt Exp $ */ /* * Copyright (c) 2001-2003 Todd C. Miller @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -76,6 +77,8 @@ const struct wi_pci_product *wi_pci_lookup(struct pci_attach_args *pa); int wi_pci_match(struct device *, void *, void *); void wi_pci_attach(struct device *, struct device *, void *); +int wi_pci_activate(struct device *, int); +void wi_pci_resume(void *arg1, void *arg2); int wi_pci_acex_attach(struct pci_attach_args *pa, struct wi_softc *sc); int wi_pci_plx_attach(struct pci_attach_args *pa, struct wi_softc *sc); int wi_pci_tmd_attach(struct pci_attach_args *pa, struct wi_softc *sc); @@ -87,10 +90,12 @@ void wi_pci_power(int, void *); struct wi_pci_softc { struct wi_softc sc_wi; /* real softc */ void *sc_powerhook; + struct workq_task sc_resume_wqt; }; struct cfattach wi_pci_ca = { - sizeof (struct wi_pci_softc), wi_pci_match, wi_pci_attach + sizeof (struct wi_pci_softc), wi_pci_match, wi_pci_attach, NULL, + wi_pci_activate }; static const struct wi_pci_product { @@ -156,6 +161,33 @@ wi_pci_attach(struct device *parent, struct device *self, void *aux) psc->sc_powerhook = powerhook_establish(wi_pci_power, sc); } +int +wi_pci_activate(struct device *self, int act) +{ + struct wi_pci_softc *psc = (struct wi_pci_softc *)self; + struct wi_softc *sc = (struct wi_softc *)self; + struct ifnet *ifp = &sc->sc_ic.ic_if; + + switch (act) { + case DVACT_SUSPEND: + if (ifp->if_flags & IFF_RUNNING) + wi_stop(sc); + break; + case DVACT_RESUME: + workq_queue_task(NULL, &psc->sc_resume_wqt, 0, + wi_pci_resume, sc, NULL); + break; + } + + return (0); +} + +void +wi_pci_resume(void *arg1, void *arg2) +{ + wi_pci_power(PWR_RESUME, arg1); +} + void wi_pci_power(int why, void *arg) {