summaryrefslogtreecommitdiff
path: root/sys/dev/pci/if_pcn.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_pcn.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_pcn.c')
-rw-r--r--sys/dev/pci/if_pcn.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/sys/dev/pci/if_pcn.c b/sys/dev/pci/if_pcn.c
index b1925658f39..089bf7f5f46 100644
--- a/sys/dev/pci/if_pcn.c
+++ b/sys/dev/pci/if_pcn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pcn.c,v 1.15 2006/11/09 14:25:23 reyk Exp $ */
+/* $OpenBSD: if_pcn.c,v 1.16 2007/10/22 03:16:35 fgsch Exp $ */
/* $NetBSD: if_pcn.c,v 1.26 2005/05/07 09:15:44 is Exp $ */
/*
@@ -584,10 +584,9 @@ pcn_attach(struct device *parent, struct device *self, void *aux)
bus_dma_segment_t seg;
int ioh_valid, memh_valid;
int i, rseg, error;
- pcireg_t pmode;
uint32_t chipid, reg;
uint8_t enaddr[ETHER_ADDR_LEN];
- int pmreg;
+ int state;
timeout_set(&sc->sc_tick_timeout, pcn_tick, sc);
@@ -614,22 +613,17 @@ pcn_attach(struct device *parent, struct device *self, void *aux)
sc->sc_dmat = pa->pa_dmat;
/* Get it out of power save mode, if needed. */
- if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, &pmreg, 0)) {
- pmode = pci_conf_read(pc, pa->pa_tag, pmreg + PCI_PMCSR) &
- PCI_PMCSR_STATE_MASK;
- if (pmode == 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 from power state D3\n");
return;
- }
- if (pmode != PCI_PMCSR_STATE_D0) {
- printf(": waking up from power date D%d",
- pmode);
- pci_conf_write(pc, pa->pa_tag, pmreg + PCI_PMCSR,
- PCI_PMCSR_STATE_D0);
+ } else {
+ printf(": waking up from power date D%d", state);
}
}