diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2010-08-27 15:41:44 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2010-08-27 15:41:44 +0000 |
commit | 331492432b764b736a5ddc8faa96012393835159 (patch) | |
tree | 7cbbf877146d72530b6aa3186fb9640dbdee133e | |
parent | 7d42a1044afc9860604cb60a5b4df01e9c9a6600 (diff) |
Improve sdhc_activate, and make sdhc_powerhook a simple wrapper around
it for now
ok kettenis
-rw-r--r-- | sys/dev/pci/sdhc_pci.c | 21 | ||||
-rw-r--r-- | sys/dev/sdmmc/sdhc.c | 31 | ||||
-rw-r--r-- | sys/dev/sdmmc/sdhcvar.h | 5 |
3 files changed, 22 insertions, 35 deletions
diff --git a/sys/dev/pci/sdhc_pci.c b/sys/dev/pci/sdhc_pci.c index 1c290a3741a..c9bd33d6446 100644 --- a/sys/dev/pci/sdhc_pci.c +++ b/sys/dev/pci/sdhc_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sdhc_pci.c,v 1.8 2010/07/01 18:08:17 deraadt Exp $ */ +/* $OpenBSD: sdhc_pci.c,v 1.9 2010/08/27 15:41:42 deraadt Exp $ */ /* * Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org> @@ -46,12 +46,11 @@ struct sdhc_pci_softc { int sdhc_pci_match(struct device *, void *, void *); void sdhc_pci_attach(struct device *, struct device *, void *); -int sdhc_pci_activate(struct device *, int act); void sdhc_takecontroller(struct pci_attach_args *); struct cfattach sdhc_pci_ca = { sizeof(struct sdhc_pci_softc), sdhc_pci_match, sdhc_pci_attach, - NULL, sdhc_pci_activate + NULL, sdhc_activate }; int @@ -146,24 +145,10 @@ sdhc_pci_attach(struct device *parent, struct device *self, void *aux) /* * Establish power and shutdown hooks. */ - (void)powerhook_establish(sdhc_power, &sc->sc); + (void)powerhook_establish(sdhc_powerhook, &sc->sc); (void)shutdownhook_establish(sdhc_shutdown, &sc->sc); } -int -sdhc_pci_activate(struct device *self, int act) -{ - switch (act) { - case DVACT_SUSPEND: - sdhc_power(PWR_SUSPEND, self); - break; - case DVACT_RESUME: - sdhc_power(PWR_RESUME, self); - break; - } - return (0); -} - void sdhc_takecontroller(struct pci_attach_args *pa) { diff --git a/sys/dev/sdmmc/sdhc.c b/sys/dev/sdmmc/sdhc.c index 0f90fdf4eae..d09d613cf89 100644 --- a/sys/dev/sdmmc/sdhc.c +++ b/sys/dev/sdmmc/sdhc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sdhc.c,v 1.29 2010/08/27 04:09:20 deraadt Exp $ */ +/* $OpenBSD: sdhc.c,v 1.30 2010/08/27 15:41:43 deraadt Exp $ */ /* * Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org> @@ -248,18 +248,15 @@ err: return (error); } -/* - * Power hook established by or called from attachment driver. - */ -void -sdhc_power(int why, void *arg) +int +sdhc_activate(struct device *self, int act) { - struct sdhc_softc *sc = arg; + struct sdhc_softc *sc = (struct sdhc_softc *)self; struct sdhc_host *hp; int n, i; - switch(why) { - case PWR_SUSPEND: + switch (act) { + case DVACT_SUSPEND: /* XXX poll for command completion or suspend command * in progress */ @@ -269,11 +266,9 @@ sdhc_power(int why, void *arg) for (i = 0; i < sizeof hp->regs; i++) hp->regs[i] = HREAD1(hp, i); } - config_activate_children((struct device *)sc, - DVACT_SUSPEND); + config_activate_children((struct device *)sc, act); break; - - case PWR_RESUME: + case DVACT_RESUME: /* Restore the host controller state. */ for (n = 0; n < sc->sc_nhosts; n++) { hp = sc->sc_host[n]; @@ -281,10 +276,16 @@ sdhc_power(int why, void *arg) for (i = 0; i < sizeof hp->regs; i++) HWRITE1(hp, i, hp->regs[i]); } - config_activate_children((struct device *)sc, - DVACT_RESUME); + config_activate_children((struct device *)sc, act); break; } + return (0); +} + +void +sdhc_powerhook(int why, void *arg) +{ + sdhc_activate(arg, why); } /* diff --git a/sys/dev/sdmmc/sdhcvar.h b/sys/dev/sdmmc/sdhcvar.h index be883e395e5..ae035232689 100644 --- a/sys/dev/sdmmc/sdhcvar.h +++ b/sys/dev/sdmmc/sdhcvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sdhcvar.h,v 1.3 2007/09/06 08:01:01 jsg Exp $ */ +/* $OpenBSD: sdhcvar.h,v 1.4 2010/08/27 15:41:43 deraadt Exp $ */ /* * Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org> @@ -33,7 +33,8 @@ struct sdhc_softc { /* Host controller functions called by the attachment driver. */ int sdhc_host_found(struct sdhc_softc *, bus_space_tag_t, bus_space_handle_t, bus_size_t, int); -void sdhc_power(int, void *); +int sdhc_activate(struct device *, int); +void sdhc_powerhook(int, void *); void sdhc_shutdown(void *); int sdhc_intr(void *); |