diff options
| author | kefren <kefren@NetBSD.org> | 2009-04-23 20:24:23 +0000 |
|---|---|---|
| committer | kefren <kefren@NetBSD.org> | 2009-04-23 20:24:23 +0000 |
| commit | 02190332dd7a18769341aedc9149a7aaab14cd43 (patch) | |
| tree | 666050b13538fb4a7f41738474d37ffbb1986bf0 /sys | |
| parent | d3dabe12604098477d59d3bb1b3ce9e91ed49c06 (diff) | |
Add power hooks. Proposed a couple of days ago on tech-kern@, no
objections received. Tested on Dell Inspiron 2200 with BCM4318
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/dev/ic/bwi.c | 24 | ||||
| -rw-r--r-- | sys/dev/ic/bwivar.h | 6 | ||||
| -rw-r--r-- | sys/dev/pci/if_bwi_pci.c | 9 |
3 files changed, 34 insertions, 5 deletions
diff --git a/sys/dev/ic/bwi.c b/sys/dev/ic/bwi.c index b98a09b3818..70b60510f7c 100644 --- a/sys/dev/ic/bwi.c +++ b/sys/dev/ic/bwi.c @@ -1,4 +1,4 @@ -/* $NetBSD: bwi.c,v 1.8 2009/04/18 14:58:02 tsutsui Exp $ */ +/* $NetBSD: bwi.c,v 1.9 2009/04/23 20:24:23 kefren Exp $ */ /* $OpenBSD: bwi.c,v 1.74 2008/02/25 21:13:30 mglocker Exp $ */ /* @@ -49,7 +49,7 @@ #include "bpfilter.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bwi.c,v 1.8 2009/04/18 14:58:02 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bwi.c,v 1.9 2009/04/23 20:24:23 kefren Exp $"); #include <sys/param.h> #include <sys/callout.h> @@ -9739,3 +9739,23 @@ bwi_calc_rssi(struct bwi_softc *sc, const struct bwi_rxbuf_hdr *hdr) return (bwi_rf_calc_rssi(mac, hdr)); } + +bool +bwi_suspend(device_t dv PMF_FN_ARGS) +{ + struct bwi_softc *sc = device_private(dv); + + bwi_power_off(sc, 0); + + return true; +} + +bool +bwi_resume(device_t dv PMF_FN_ARGS) +{ + struct bwi_softc *sc = device_private(dv); + + bwi_power_on(sc, 1); + + return true; +} diff --git a/sys/dev/ic/bwivar.h b/sys/dev/ic/bwivar.h index 3b81af29d4f..531a7a53ae6 100644 --- a/sys/dev/ic/bwivar.h +++ b/sys/dev/ic/bwivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: bwivar.h,v 1.2 2009/01/09 20:49:42 macallan Exp $ */ +/* $NetBSD: bwivar.h,v 1.3 2009/04/23 20:24:23 kefren Exp $ */ /* $OpenBSD: bwivar.h,v 1.23 2008/02/25 20:36:54 mglocker Exp $ */ /* @@ -791,4 +791,8 @@ int bwi_intr(void *); int bwi_attach(struct bwi_softc *); void bwi_detach(struct bwi_softc *); +/* Power Management Framework */ +bool bwi_suspend(device_t db PMF_FN_ARGS); +bool bwi_resume(device_t db PMF_FN_ARGS); + #endif /* !_DEV_IC_BWIVAR_H */ diff --git a/sys/dev/pci/if_bwi_pci.c b/sys/dev/pci/if_bwi_pci.c index 014390f04ab..092ef2df023 100644 --- a/sys/dev/pci/if_bwi_pci.c +++ b/sys/dev/pci/if_bwi_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_bwi_pci.c,v 1.3 2009/01/10 12:55:45 cegger Exp $ */ +/* $NetBSD: if_bwi_pci.c,v 1.4 2009/04/23 20:24:23 kefren Exp $ */ /* $OpenBSD: if_bwi_pci.c,v 1.6 2008/02/14 22:10:02 brad Exp $ */ /* @@ -25,7 +25,7 @@ #include "bpfilter.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_bwi_pci.c,v 1.3 2009/01/10 12:55:45 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_bwi_pci.c,v 1.4 2009/04/23 20:24:23 kefren Exp $"); #include <sys/param.h> #include <sys/callout.h> @@ -161,6 +161,9 @@ bwi_pci_attach(struct device *parent, struct device *self, void *aux) sc->sc_pci_subvid = PCI_VENDOR(reg); sc->sc_pci_subdid = PCI_PRODUCT(reg); + if (!pmf_device_register(self, bwi_suspend, bwi_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + bwi_attach(sc); } @@ -170,6 +173,8 @@ bwi_pci_detach(struct device *self, int flags) struct bwi_pci_softc *psc = (struct bwi_pci_softc *)self; struct bwi_softc *sc = &psc->psc_bwi; + pmf_device_deregister(self); + bwi_detach(sc); if (sc->sc_ih != NULL) { |
