From 95d74b5f332b0012dd590b458184bba2fbf2259b Mon Sep 17 00:00:00 2001 From: kettenis Date: Wed, 21 Jul 2010 14:01:58 +0000 Subject: [PATCH] Add suspend/unsuspend logic. ok damien@, deraadt@ --- sys/dev/ic/athn.c | 22 +++++++++++++++++++++- sys/dev/ic/athnvar.h | 4 +++- sys/dev/pci/if_athn_pci.c | 23 +++++++++++++++++++++-- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/sys/dev/ic/athn.c b/sys/dev/ic/athn.c index 9f8f0c6f911..37408408522 100644 --- a/sys/dev/ic/athn.c +++ b/sys/dev/ic/athn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: athn.c,v 1.55 2010/07/15 20:37:38 damien Exp $ */ +/* $OpenBSD: athn.c,v 1.56 2010/07/21 14:01:58 kettenis Exp $ */ /*- * Copyright (c) 2009 Damien Bergamini @@ -2701,3 +2701,23 @@ athn_stop(struct ifnet *ifp, int disable) if (disable && sc->sc_disable != NULL) sc->sc_disable(sc); } + +void +athn_suspend(struct athn_softc *sc) +{ + struct ifnet *ifp = &sc->sc_ic.ic_if; + + athn_stop(ifp, 1); +} + +void +athn_resume(struct athn_softc *sc) +{ + struct ifnet *ifp = &sc->sc_ic.ic_if; + + if (ifp->if_flags & IFF_UP) { + athn_init(ifp); + if (ifp->if_flags & IFF_RUNNING) + athn_start(ifp); + } +} diff --git a/sys/dev/ic/athnvar.h b/sys/dev/ic/athnvar.h index a49c0c3eb24..034189361b6 100644 --- a/sys/dev/ic/athnvar.h +++ b/sys/dev/ic/athnvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: athnvar.h,v 1.19 2010/07/15 20:37:38 damien Exp $ */ +/* $OpenBSD: athnvar.h,v 1.20 2010/07/21 14:01:58 kettenis Exp $ */ /*- * Copyright (c) 2009 Damien Bergamini @@ -555,4 +555,6 @@ struct athn_softc { extern int athn_attach(struct athn_softc *); extern void athn_detach(struct athn_softc *); +extern void athn_suspend(struct athn_softc *); +extern void athn_resume(struct athn_softc *); extern int athn_intr(void *); diff --git a/sys/dev/pci/if_athn_pci.c b/sys/dev/pci/if_athn_pci.c index fad7aa668ee..d8aad078748 100644 --- a/sys/dev/pci/if_athn_pci.c +++ b/sys/dev/pci/if_athn_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_athn_pci.c,v 1.6 2010/05/16 15:06:22 damien Exp $ */ +/* $OpenBSD: if_athn_pci.c,v 1.7 2010/07/21 14:01:58 kettenis Exp $ */ /*- * Copyright (c) 2009 Damien Bergamini @@ -71,13 +71,15 @@ struct athn_pci_softc { int athn_pci_match(struct device *, void *, void *); void athn_pci_attach(struct device *, struct device *, void *); int athn_pci_detach(struct device *, int); +int athn_pci_activate(struct device *, int); void athn_pci_disable_aspm(struct athn_softc *); struct cfattach athn_pci_ca = { sizeof (struct athn_pci_softc), athn_pci_match, athn_pci_attach, - athn_pci_detach + athn_pci_detach, + athn_pci_activate }; static const struct pci_matchid athn_pci_devices[] = { @@ -194,6 +196,23 @@ athn_pci_detach(struct device *self, int flags) return (0); } +int +athn_pci_activate(struct device *self, int act) +{ + struct athn_softc *sc = (struct athn_softc *)self; + + switch (act) { + case DVACT_SUSPEND: + athn_suspend(sc); + break; + case DVACT_RESUME: + athn_resume(sc); + break; + } + + return (0); +} + void athn_pci_disable_aspm(struct athn_softc *sc) { -- 2.20.1