-/* $OpenBSD: if_ipw.c,v 1.86 2010/04/20 22:05:43 tedu Exp $ */
+/* $OpenBSD: if_ipw.c,v 1.87 2010/07/28 21:21:38 deraadt Exp $ */
/*-
* Copyright (c) 2004-2008
int ipw_match(struct device *, void *, void *);
void ipw_attach(struct device *, struct device *, void *);
+int ipw_activate(struct device *, int);
+void ipw_resume(void *, void *);
void ipw_power(int, void *);
int ipw_dma_alloc(struct ipw_softc *);
void ipw_release(struct ipw_softc *);
#endif
struct cfattach ipw_ca = {
- sizeof (struct ipw_softc), ipw_match, ipw_attach
+ sizeof (struct ipw_softc), ipw_match, ipw_attach, NULL,
+ ipw_activate
};
int
#endif
}
+int
+ipw_activate(struct device *self, int act)
+{
+ struct ipw_softc *sc = (struct ipw_softc *)self;
+ struct ifnet *ifp = &sc->sc_ic.ic_if;
+
+ switch (act) {
+ case DVACT_SUSPEND:
+ if (ifp->if_flags & IFF_RUNNING)
+ ipw_stop(ifp, 0);
+ break;
+ case DVACT_RESUME:
+ workq_queue_task(NULL, &sc->sc_resume_wqt, 0,
+ ipw_resume, sc, NULL);
+ break;
+ }
+
+ return (0);
+}
+
+void
+ipw_resume(void *arg1, void *arg2)
+{
+ ipw_power(PWR_RESUME, arg1);
+}
+
void
ipw_power(int why, void *arg)
{
struct ipw_softc *sc = arg;
- struct ifnet *ifp;
+ struct ifnet *ifp = &sc->sc_ic.ic_if;
pcireg_t data;
- if (why != PWR_RESUME)
+ if (why != PWR_RESUME) {
+ ipw_stop(ifp, 0);
return;
+ }
/* clear device specific PCI configuration register 0x41 */
data = pci_conf_read(sc->sc_pct, sc->sc_pcitag, 0x40);
data &= ~0x0000ff00;
pci_conf_write(sc->sc_pct, sc->sc_pcitag, 0x40, data);
- ifp = &sc->sc_ic.ic_if;
- if (ifp->if_flags & IFF_UP) {
- ifp->if_init(ifp);
- if (ifp->if_flags & IFF_RUNNING)
- ifp->if_start(ifp);
- }
+ if (ifp->if_flags & IFF_UP)
+ ipw_init(ifp);
}
int
-/* $OpenBSD: if_ipwvar.h,v 1.18 2008/08/28 15:08:38 damien Exp $ */
+/* $OpenBSD: if_ipwvar.h,v 1.19 2010/07/28 21:21:38 deraadt Exp $ */
/*-
* Copyright (c) 2004-2006
int txfree;
void *powerhook;
+ struct workq_task sc_resume_wqt;
#if NBPFILTER > 0
caddr_t sc_drvbpf;
-/* $OpenBSD: if_iwi.c,v 1.103 2010/05/19 15:27:35 oga Exp $ */
+/* $OpenBSD: if_iwi.c,v 1.104 2010/07/28 21:21:38 deraadt Exp $ */
/*-
* Copyright (c) 2004-2008
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/device.h>
+#include <sys/workq.h>
#include <machine/bus.h>
#include <machine/endian.h>
int iwi_match(struct device *, void *, void *);
void iwi_attach(struct device *, struct device *, void *);
+int iwi_activate(struct device *, int);
+void iwi_resume(void *, void *);
void iwi_power(int, void *);
int iwi_alloc_cmd_ring(struct iwi_softc *, struct iwi_cmd_ring *);
void iwi_reset_cmd_ring(struct iwi_softc *, struct iwi_cmd_ring *);
#endif
struct cfattach iwi_ca = {
- sizeof (struct iwi_softc), iwi_match, iwi_attach
+ sizeof (struct iwi_softc), iwi_match, iwi_attach, NULL,
+ iwi_activate
};
int
iwi_free_cmd_ring(sc, &sc->cmdq);
}
+int
+iwi_activate(struct device *self, int act)
+{
+ struct iwi_softc *sc = (struct iwi_softc *)self;
+ struct ifnet *ifp = &sc->sc_ic.ic_if;
+
+ switch (act) {
+ case DVACT_SUSPEND:
+ if (ifp->if_flags & IFF_RUNNING)
+ iwi_stop(ifp, 0);
+ break;
+ case DVACT_RESUME:
+ workq_queue_task(NULL, &sc->sc_resume_wqt, 0,
+ iwi_resume, sc, NULL);
+ break;
+ }
+
+ return (0);
+}
+
+void
+iwi_resume(void *arg1, void *arg2)
+{
+ iwi_power(PWR_RESUME, arg1);
+}
+
void
iwi_power(int why, void *arg)
{
struct iwi_softc *sc = arg;
- struct ifnet *ifp;
+ struct ifnet *ifp = &sc->sc_ic.ic_if;
pcireg_t data;
int s;
- if (why != PWR_RESUME)
+ if (why != PWR_RESUME) {
+ iwi_stop(ifp, 0);
return;
+ }
/* clear device specific PCI configuration register 0x41 */
data = pci_conf_read(sc->sc_pct, sc->sc_pcitag, 0x40);
pci_conf_write(sc->sc_pct, sc->sc_pcitag, 0x40, data);
s = splnet();
- ifp = &sc->sc_ic.ic_if;
- if (ifp->if_flags & IFF_UP) {
- ifp->if_init(ifp);
- if (ifp->if_flags & IFF_RUNNING)
- ifp->if_start(ifp);
- }
+ if (ifp->if_flags & IFF_UP)
+ iwi_init(ifp);
splx(s);
}
-/* $OpenBSD: if_iwivar.h,v 1.20 2009/06/05 22:40:31 deraadt Exp $ */
+/* $OpenBSD: if_iwivar.h,v 1.21 2010/07/28 21:21:38 deraadt Exp $ */
/*-
* Copyright (c) 2004-2006
int sc_tx_timer;
void *powerhook;
+ struct workq_task sc_resume_wqt;
#if NBPFILTER > 0
caddr_t sc_drvbpf;
-/* $OpenBSD: if_iwn.c,v 1.99 2010/07/23 06:43:00 phessler Exp $ */
+/* $OpenBSD: if_iwn.c,v 1.100 2010/07/28 21:21:38 deraadt Exp $ */
/*-
* Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr>
switch (act) {
case DVACT_SUSPEND:
if (ifp->if_flags & IFF_RUNNING)
- iwn_stop(ifp, 1);
+ iwn_stop(ifp, 0);
break;
case DVACT_RESUME:
workq_queue_task(NULL, &sc->sc_resume_wqt, 0,
iwn_power(int why, void *arg)
{
struct iwn_softc *sc = arg;
- struct ifnet *ifp;
+ struct ifnet *ifp = &sc->sc_ic.ic_if;
pcireg_t reg;
int s;
- if (why != PWR_RESUME)
+ if (why != PWR_RESUME) {
+ iwn_stop(ifp, 0);
return;
+ }
/* Clear device-specific "PCI retry timeout" register (41h). */
reg = pci_conf_read(sc->sc_pct, sc->sc_pcitag, 0x40);
s = splnet();
sc->sc_flags |= IWN_FLAG_BUSY;
- ifp = &sc->sc_ic.ic_if;
- if (ifp->if_flags & IFF_UP) {
- ifp->if_init(ifp);
- if (ifp->if_flags & IFF_RUNNING)
- ifp->if_start(ifp);
- }
+ if (ifp->if_flags & IFF_UP)
+ iwn_init(ifp);
sc->sc_flags &= ~IWN_FLAG_BUSY;
splx(s);
-/* $OpenBSD: if_wpi.c,v 1.102 2010/07/22 14:42:43 kettenis Exp $ */
+/* $OpenBSD: if_wpi.c,v 1.103 2010/07/28 21:21:38 deraadt Exp $ */
/*-
* Copyright (c) 2006-2008
switch (act) {
case DVACT_SUSPEND:
if (ifp->if_flags & IFF_RUNNING)
- wpi_stop(ifp, 1);
+ wpi_stop(ifp, 0);
break;
case DVACT_RESUME:
workq_queue_task(NULL, &sc->sc_resume_wqt, 0,
wpi_power(int why, void *arg)
{
struct wpi_softc *sc = arg;
- struct ifnet *ifp;
+ struct ifnet *ifp = &sc->sc_ic.ic_if;
pcireg_t reg;
int s;
- if (why != PWR_RESUME)
+ if (why != PWR_RESUME) {
+ wpi_stop(ifp, 0);
return;
+ }
/* Clear device-specific "PCI retry timeout" register (41h). */
reg = pci_conf_read(sc->sc_pct, sc->sc_pcitag, 0x40);
s = splnet();
sc->sc_flags |= WPI_FLAG_BUSY;
- ifp = &sc->sc_ic.ic_if;
if (ifp->if_flags & IFF_UP) {
ifp->if_init(ifp);
if (ifp->if_flags & IFF_RUNNING)