summaryrefslogtreecommitdiff
path: root/sys/dev/pci/if_atw_pci.c
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2007-10-22 03:16:36 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2007-10-22 03:16:36 +0000
commitd4c68f93dc3b59f50991aad50fc6d1175f988124 (patch)
tree28aef8afa5df31eb49206fc5747c4a1bb9d600df /sys/dev/pci/if_atw_pci.c
parentd69e7e7d6e618c28d4b1141d46816e29b42e3cfd (diff)
Use pci_set_powerstate(), shrinking the code and unifying the different
versions. ok by many.
Diffstat (limited to 'sys/dev/pci/if_atw_pci.c')
-rw-r--r--sys/dev/pci/if_atw_pci.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/sys/dev/pci/if_atw_pci.c b/sys/dev/pci/if_atw_pci.c
index 621c9aa35b8..170d1b53edc 100644
--- a/sys/dev/pci/if_atw_pci.c
+++ b/sys/dev/pci/if_atw_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_atw_pci.c,v 1.7 2005/09/08 12:44:55 jsg Exp $ */
+/* $OpenBSD: if_atw_pci.c,v 1.8 2007/10/22 03:16:35 fgsch Exp $ */
/* $NetBSD: if_atw_pci.c,v 1.7 2004/07/23 07:07:55 dyoung Exp $ */
/*-
@@ -151,8 +151,7 @@ atw_pci_attach(struct device *parent, struct device *self, void *aux)
bus_space_tag_t iot, memt;
bus_space_handle_t ioh, memh;
int ioh_valid, memh_valid;
- pcireg_t reg;
- int pmreg;
+ int state;
psc->psc_pc = pa->pa_pc;
psc->psc_pcitag = pa->pa_tag;
@@ -178,28 +177,19 @@ atw_pci_attach(struct device *parent, struct device *self, void *aux)
* same place in the ADM8211, but the docs do not assign its bits
* any meanings. -dcy
*/
- if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, &pmreg, 0)) {
- reg = pci_conf_read(pc, pa->pa_tag, pmreg + PCI_PMCSR);
- switch (reg & PCI_PMCSR_STATE_MASK) {
- case PCI_PMCSR_STATE_D1:
- case PCI_PMCSR_STATE_D2:
- printf(": waking up from power state D%d\n%s",
- reg & PCI_PMCSR_STATE_MASK, sc->sc_dev.dv_xname);
- pci_conf_write(pc, pa->pa_tag, pmreg + PCI_PMCSR,
- (reg & ~PCI_PMCSR_STATE_MASK) |
- PCI_PMCSR_STATE_D0);
- break;
- case PCI_PMCSR_STATE_D3:
+ state = pci_set_powerstate(pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
+ if (state != PCI_PMCSR_STATE_D0) {
+ if (state == PCI_PMCSR_STATE_D3) {
/*
* The card has lost all configuration data in
* this state, so punt.
*/
printf(": unable to wake up from power state D3, "
- "reboot required.\n");
- pci_conf_write(pc, pa->pa_tag, pmreg + PCI_PMCSR,
- (reg & ~PCI_PMCSR_STATE_MASK) |
- PCI_PMCSR_STATE_D0);
+ "reboot required.\n");
return;
+ } else {
+ printf(": waking up from power state D%d\n%s",
+ state, sc->sc_dev.dv_xname);
}
}