diff options
Diffstat (limited to 'sys/dev/pci/cs4280.c')
-rw-r--r-- | sys/dev/pci/cs4280.c | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/sys/dev/pci/cs4280.c b/sys/dev/pci/cs4280.c index 8d278d9e9b8..92d4572f12c 100644 --- a/sys/dev/pci/cs4280.c +++ b/sys/dev/pci/cs4280.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cs4280.c,v 1.34 2010/07/15 03:43:11 jakemsr Exp $ */ +/* $OpenBSD: cs4280.c,v 1.35 2010/08/27 18:50:57 deraadt Exp $ */ /* $NetBSD: cs4280.c,v 1.5 2000/06/26 04:56:23 simonb Exp $ */ /* @@ -157,7 +157,6 @@ struct cs4280_softc { struct ac97_codec_if *codec_if; struct ac97_host_if host_if; - char sc_suspend; void *sc_powerhook; /* Power Hook */ u_int16_t ac97_reg[CS4280_SAVE_REG_MAX + 1]; /* Save ac97 registers */ }; @@ -169,6 +168,7 @@ struct cs4280_softc { int cs4280_match(struct device *, void *, void *); void cs4280_attach(struct device *, struct device *, void *); +int cs4280_activate(struct device *, int); void cs4280_attachhook(void *xsc); int cs4280_intr(void *); void cs4280_reset(void *); @@ -190,7 +190,8 @@ struct cfdriver clcs_cd = { }; struct cfattach clcs_ca = { - sizeof(struct cs4280_softc), cs4280_match, cs4280_attach + sizeof(struct cs4280_softc), cs4280_match, cs4280_attach, NULL, + cs4280_activate }; int cs4280_init(struct cs4280_softc *, int); @@ -232,7 +233,7 @@ int cs4280_read_codec(void *sc, u_int8_t a, u_int16_t *d); int cs4280_write_codec(void *sc, u_int8_t a, u_int16_t d); void cs4280_reset_codec(void *sc); -void cs4280_power(int, void *); +void cs4280_powerhook(int, void *); void cs4280_clear_fifos(struct cs4280_softc *); @@ -590,8 +591,7 @@ cs4280_attachhook(void *xsc) #if NMIDI > 0 midi_attach_mi(&cs4280_midi_hw_if, sc, &sc->sc_dev); #endif - sc->sc_suspend = PWR_RESUME; - sc->sc_powerhook = powerhook_establish(cs4280_power, sc); + sc->sc_powerhook = powerhook_establish(cs4280_powerhook, sc); } void @@ -1829,19 +1829,14 @@ cs4280_init2(sc, init) return(0); } -void -cs4280_power(why, v) - int why; - void *v; +int +cs4280_activate(struct device *self, int act) { - struct cs4280_softc *sc = (struct cs4280_softc *)v; + struct cs4280_softc *sc = (struct cs4280_softc *)self; int i; - DPRINTF(("%s: cs4280_power why=%d\n", - sc->sc_dev.dv_xname, why)); - if (why != PWR_RESUME) { - sc->sc_suspend = why; - + switch (act) { + case DVACT_SUSPEND: cs4280_halt_output(sc); cs4280_halt_input(sc); /* Save AC97 registers */ @@ -1852,13 +1847,8 @@ cs4280_power(why, v) } /* should I powerdown here ? */ cs4280_write_codec(sc, AC97_REG_POWER, CS4280_POWER_DOWN_ALL); - } else { - if (sc->sc_suspend == PWR_RESUME) { - printf("cs4280_power: odd, resume without suspend.\n"); - sc->sc_suspend = why; - return; - } - sc->sc_suspend = why; + break; + case DVACT_RESUME: cs4280_init(sc, 0); cs4280_init2(sc, 0); cs4280_reset_codec(sc); @@ -1869,7 +1859,15 @@ cs4280_power(why, v) continue; cs4280_write_codec(sc, 2*i, sc->ac97_reg[i]); } + break; } + return 0; +} + +void +cs4280_powerhook(int why, void *v) +{ + cs4280_activate(v, why); } void |