diff options
author | 2013-05-30 16:15:01 +0000 | |
---|---|---|
committer | 2013-05-30 16:15:01 +0000 | |
commit | c06fda6d0724f63f24685adf5b3d7f3ead24829d (patch) | |
tree | 1f027428818a55ed1ab7b65fb609867de3c20ad9 /sys/dev | |
parent | Simplify hello holdtime calculation and stop the timeout timer if the (diff) | |
download | wireguard-openbsd-c06fda6d0724f63f24685adf5b3d7f3ead24829d.tar.xz wireguard-openbsd-c06fda6d0724f63f24685adf5b3d7f3ead24829d.zip |
Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too
Diffstat (limited to 'sys/dev')
38 files changed, 288 insertions, 231 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 603122a5f7e..8a43fb85352 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.243 2013/04/18 18:30:41 deraadt Exp $ */ +/* $OpenBSD: acpi.c,v 1.244 2013/05/30 16:15:01 deraadt Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -154,8 +154,7 @@ void acpi_disable_allgpes(struct acpi_softc *); extern struct aml_node aml_root; struct cfattach acpi_ca = { - sizeof(struct acpi_softc), acpi_match, acpi_attach, NULL, - config_activate_children + sizeof(struct acpi_softc), acpi_match, acpi_attach }; struct cfdriver acpi_cd = { diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c index 6786f0fb293..4e8d4d814e8 100644 --- a/sys/dev/cardbus/cardbus.c +++ b/sys/dev/cardbus/cardbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cardbus.c,v 1.45 2010/08/25 21:37:59 kettenis Exp $ */ +/* $OpenBSD: cardbus.c,v 1.46 2013/05/30 16:15:01 deraadt Exp $ */ /* $NetBSD: cardbus.c,v 1.24 2000/04/02 19:11:37 mycroft Exp $ */ /* @@ -83,8 +83,7 @@ STATIC void disable_function(struct cardbus_softc *, int); struct cfattach cardbus_ca = { - sizeof(struct cardbus_softc), cardbusmatch, cardbusattach, - NULL, config_activate_children + sizeof(struct cardbus_softc), cardbusmatch, cardbusattach }; struct cfdriver cardbus_cd = { diff --git a/sys/dev/cardbus/cardslot.c b/sys/dev/cardbus/cardslot.c index 0061e48ec32..d4fb6b41f85 100644 --- a/sys/dev/cardbus/cardslot.c +++ b/sys/dev/cardbus/cardslot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cardslot.c,v 1.14 2010/08/25 21:37:59 kettenis Exp $ */ +/* $OpenBSD: cardslot.c,v 1.15 2013/05/30 16:15:01 deraadt Exp $ */ /* $NetBSD: cardslot.c,v 1.9 2000/03/22 09:35:06 haya Exp $ */ /* @@ -68,8 +68,7 @@ STATIC int cardslot_16_print(void *, const char *); STATIC int cardslot_16_submatch(struct device *, void *,void *); struct cfattach cardslot_ca = { - sizeof(struct cardslot_softc), cardslotmatch, cardslotattach, - NULL, config_activate_children + sizeof(struct cardslot_softc), cardslotmatch, cardslotattach }; struct cfdriver cardslot_cd = { diff --git a/sys/dev/flash.c b/sys/dev/flash.c index 8f5dd8dd48f..5cc8c817417 100644 --- a/sys/dev/flash.c +++ b/sys/dev/flash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: flash.c,v 1.24 2011/07/06 04:49:36 matthew Exp $ */ +/* $OpenBSD: flash.c,v 1.25 2013/05/30 16:15:01 deraadt Exp $ */ /* * Copyright (c) 2005 Uwe Stuehler <uwe@openbsd.org> @@ -172,13 +172,6 @@ flashdetach(struct device *self, int flags) return 0; } -int -flashactivate(struct device *self, int act) -{ - /* XXX anything to be done here? */ - return 0; -} - /* * Flash controller and chip functions */ diff --git a/sys/dev/flashvar.h b/sys/dev/flashvar.h index 1985a6b01ef..0541cbefb03 100644 --- a/sys/dev/flashvar.h +++ b/sys/dev/flashvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: flashvar.h,v 1.5 2009/10/13 19:33:16 pirofti Exp $ */ +/* $OpenBSD: flashvar.h,v 1.6 2013/05/30 16:15:01 deraadt Exp $ */ /* * Copyright (c) 2005 Uwe Stuehler <uwe@openbsd.org> @@ -116,7 +116,6 @@ struct flash_softc { void flashattach(struct flash_softc *, struct flash_ctl_tag *, void *); int flashdetach(struct device *, int); -int flashactivate(struct device *, int); u_int8_t flash_reg8_read(struct flash_softc *, int); void flash_reg8_read_page(struct flash_softc *, caddr_t, caddr_t); diff --git a/sys/dev/i2o/iop.c b/sys/dev/i2o/iop.c index 91f8da3d670..1b00a6720a7 100644 --- a/sys/dev/i2o/iop.c +++ b/sys/dev/i2o/iop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iop.c,v 1.37 2010/01/13 00:31:04 chl Exp $ */ +/* $OpenBSD: iop.c,v 1.38 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: iop.c,v 1.12 2001/03/21 14:27:05 ad Exp $ */ /*- @@ -204,7 +204,6 @@ void iop_configure_devices(struct iop_softc *, int, int); void iop_devinfo(int, char *, size_t); int iop_print(void *, const char *); int iop_reconfigure(struct iop_softc *, u_int); -void iop_shutdown(void *); int iop_submatch(struct device *, void *, void *); #ifdef notyet int iop_vendor_print(void *, const char *); @@ -376,10 +375,6 @@ iop_init(struct iop_softc *sc, const char *intrstr) goto bail_out; } - /* Configure shutdown hook before we start any device activity. */ - if (iop_sdh == NULL) - iop_sdh = shutdownhook_establish(iop_shutdown, NULL); - /* Ensure interrupts are enabled at the IOP. */ mask = iop_inl(sc, IOP_REG_INTR_MASK); iop_outl(sc, IOP_REG_INTR_MASK, mask & ~IOP_INTR_OFIFO); @@ -858,35 +853,27 @@ iop_submatch(struct device *parent, void *vcf, void *aux) * Shut down all configured IOPs. */ void -iop_shutdown(void *junk) +iop_shutdown(void *v) { - struct iop_softc *sc; - int i; + struct iop_softc *sc = v; - printf("shutting down iop devices..."); - - for (i = 0; i < iop_cd.cd_ndevs; i++) { - if (!(sc = (struct iop_softc *)device_lookup(&iop_cd, i))) - continue; - if ((sc->sc_flags & IOP_ONLINE) == 0) - continue; + if ((sc->sc_flags & IOP_ONLINE) == 0) + return; - iop_simple_cmd(sc, I2O_TID_IOP, I2O_EXEC_SYS_QUIESCE, IOP_ICTX, - 0, 5000); + iop_simple_cmd(sc, I2O_TID_IOP, I2O_EXEC_SYS_QUIESCE, IOP_ICTX, + 0, 5000); - if (letoh16(sc->sc_status.orgid) != I2O_ORG_AMI) { - /* - * Some AMI firmware revisions will go to sleep and - * never come back after this. - */ - iop_simple_cmd(sc, I2O_TID_IOP, I2O_EXEC_IOP_CLEAR, - IOP_ICTX, 0, 1000); - } + if (letoh16(sc->sc_status.orgid) != I2O_ORG_AMI) { + /* + * Some AMI firmware revisions will go to sleep and + * never come back after this. + */ + iop_simple_cmd(sc, I2O_TID_IOP, I2O_EXEC_IOP_CLEAR, + IOP_ICTX, 0, 1000); } /* Wait. Some boards could still be flushing, stupidly enough. */ delay(5000*1000); - printf(" done.\n"); } /* diff --git a/sys/dev/i2o/iopvar.h b/sys/dev/i2o/iopvar.h index 60a19493101..13ebdc51320 100644 --- a/sys/dev/i2o/iopvar.h +++ b/sys/dev/i2o/iopvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: iopvar.h,v 1.10 2009/04/02 18:44:49 oga Exp $ */ +/* $OpenBSD: iopvar.h,v 1.11 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: iopvar.h,v 1.5 2001/03/20 13:01:49 ad Exp $ */ /*- @@ -167,6 +167,7 @@ int iop_param_op(struct iop_softc *, int, struct iop_initiator *, int, int iop_print_ident(struct iop_softc *, int); int iop_simple_cmd(struct iop_softc *, int, int, int, int, int); void iop_strvis(struct iop_softc *, const char *, int, char *, int); +void iop_shutdown(void *); void iop_initiator_register(struct iop_softc *, struct iop_initiator *); void iop_initiator_unregister(struct iop_softc *, struct iop_initiator *); diff --git a/sys/dev/ic/aac.c b/sys/dev/ic/aac.c index 61d936b7bca..bf1938d1b4f 100644 --- a/sys/dev/ic/aac.c +++ b/sys/dev/ic/aac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aac.c,v 1.54 2011/07/17 22:46:48 matthew Exp $ */ +/* $OpenBSD: aac.c,v 1.55 2013/05/30 16:15:02 deraadt Exp $ */ /*- * Copyright (c) 2000 Michael Smith @@ -276,11 +276,6 @@ aac_attach(struct aac_softc *sc) sc->aifflags = 0; kthread_create_deferred(aac_create_thread, sc); -#if 0 - /* Register the shutdown method to only be called post-dump */ - sc->aac_sdh = shutdownhook_establish(aac_shutdown, (void *)sc); -#endif - return (0); } diff --git a/sys/dev/ic/aic79xx.c b/sys/dev/ic/aic79xx.c index 6fed99b0324..0e954fc502e 100644 --- a/sys/dev/ic/aic79xx.c +++ b/sys/dev/ic/aic79xx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aic79xx.c,v 1.50 2012/12/05 23:20:16 deraadt Exp $ */ +/* $OpenBSD: aic79xx.c,v 1.51 2013/05/30 16:15:02 deraadt Exp $ */ /* * Copyright (c) 2004 Milos Urbanek, Kenneth R. Westerback & Marco Peereboom @@ -6343,9 +6343,6 @@ init_done: ahd_restart(ahd); aic_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_MS, ahd_stat_timer, ahd); - - /* We have to wait until after any system dumps... */ - ahd->shutdown_hook = shutdownhook_establish(ahd_shutdown, ahd); return (0); } diff --git a/sys/dev/ic/aic79xx_openbsd.c b/sys/dev/ic/aic79xx_openbsd.c index a2184e4c593..760fae2a9a5 100644 --- a/sys/dev/ic/aic79xx_openbsd.c +++ b/sys/dev/ic/aic79xx_openbsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aic79xx_openbsd.c,v 1.39 2012/12/05 23:20:16 deraadt Exp $ */ +/* $OpenBSD: aic79xx_openbsd.c,v 1.40 2013/05/30 16:15:02 deraadt Exp $ */ /* * Copyright (c) 2004 Milos Urbanek, Kenneth R. Westerback & Marco Peereboom @@ -612,9 +612,6 @@ ahd_detach(struct device *self, int flags) if (ahd->sc_child != NULL) rv = config_detach((void *)ahd->sc_child, flags); - if (ahd->shutdown_hook != NULL) - shutdownhook_disestablish(ahd->shutdown_hook); - ahd_free(ahd); return rv; diff --git a/sys/dev/ic/cac.c b/sys/dev/ic/cac.c index 4c299cdd8dd..d19899b87bc 100644 --- a/sys/dev/ic/cac.c +++ b/sys/dev/ic/cac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cac.c,v 1.49 2011/10/27 00:18:23 krw Exp $ */ +/* $OpenBSD: cac.c,v 1.50 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: cac.c,v 1.15 2000/11/08 19:20:35 ad Exp $ */ /* @@ -111,8 +111,6 @@ int cac_ccb_start(struct cac_softc *, struct cac_ccb *); int cac_cmd(struct cac_softc *sc, int command, void *data, int datasize, int drive, int blkno, int flags, struct scsi_xfer *xs); int cac_get_dinfo(struct cac_softc *sc, int target); -int cac_flush(struct cac_softc *sc); -void cac_shutdown(void *); void cac_copy_internal_data(struct scsi_xfer *xs, void *v, size_t size); struct cac_ccb *cac_l0_completed(struct cac_softc *); @@ -131,8 +129,6 @@ void cac_sensor_refresh(void *); #endif #endif /* NBIO > 0 */ -void *cac_sdh; /* shutdown hook */ - const struct cac_linkage cac_l0 = { cac_l0_completed, @@ -256,10 +252,6 @@ cac_init(struct cac_softc *sc, int startfw) config_found(&sc->sc_dv, &saa, scsiprint); - /* Set our `shutdownhook' before we start any device activity. */ - if (cac_sdh == NULL) - cac_sdh = shutdownhook_establish(cac_shutdown, NULL); - (*sc->sc_cl->cl_intr_enable)(sc, 1); #if NBIO > 0 @@ -292,23 +284,6 @@ cac_flush(sc) } /* - * Shut down all `cac' controllers. - */ -void -cac_shutdown(void *cookie) -{ - extern struct cfdriver cac_cd; - struct cac_softc *sc; - int i; - - for (i = 0; i < cac_cd.cd_ndevs; i++) { - if ((sc = (struct cac_softc *)device_lookup(&cac_cd, i)) == NULL) - continue; - cac_flush(sc); - } -} - -/* * Handle an interrupt from the controller: process finished CCBs and * dequeue any waiting CCBs. */ diff --git a/sys/dev/ic/cacvar.h b/sys/dev/ic/cacvar.h index 4026323d578..0138d43e284 100644 --- a/sys/dev/ic/cacvar.h +++ b/sys/dev/ic/cacvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cacvar.h,v 1.6 2011/04/21 23:10:08 krw Exp $ */ +/* $OpenBSD: cacvar.h,v 1.7 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: cacvar.h,v 1.7 2000/10/19 14:28:47 ad Exp $ */ /*- @@ -122,6 +122,7 @@ typedef int cac_lock_t; int cac_init(struct cac_softc *, int); int cac_intr(void *); +int cac_flush(struct cac_softc *); extern const struct cac_linkage cac_l0; diff --git a/sys/dev/ic/ciss.c b/sys/dev/ic/ciss.c index 7a0e6ce660a..c9a4fa1a1f4 100644 --- a/sys/dev/ic/ciss.c +++ b/sys/dev/ic/ciss.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ciss.c,v 1.67 2011/11/10 12:05:11 krw Exp $ */ +/* $OpenBSD: ciss.c,v 1.68 2013/05/30 16:15:02 deraadt Exp $ */ /* * Copyright (c) 2005,2006 Michael Shalayeff @@ -81,7 +81,6 @@ int ciss_ioctl(struct device *, u_long, caddr_t); #endif int ciss_sync(struct ciss_softc *sc); void ciss_heartbeat(void *v); -void ciss_shutdown(void *v); #ifndef SMALL_KERNEL void ciss_sensors(void *); #endif @@ -356,12 +355,6 @@ ciss_attach(struct ciss_softc *sc) } sc->sc_flush = CISS_FLUSH_ENABLE; - if (!(sc->sc_sh = shutdownhook_establish(ciss_shutdown, sc))) { - printf(": unable to establish shutdown hook\n"); - bus_dmamem_free(sc->dmat, sc->cmdseg, 1); - bus_dmamap_destroy(sc->dmat, sc->cmdmap); - return -1; - } sc->sc_link.adapter_softc = sc; sc->sc_link.openings = sc->maxcmd; diff --git a/sys/dev/ic/cissvar.h b/sys/dev/ic/cissvar.h index c6fba9d86aa..95fb6f19668 100644 --- a/sys/dev/ic/cissvar.h +++ b/sys/dev/ic/cissvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cissvar.h,v 1.14 2010/06/03 01:03:55 dlg Exp $ */ +/* $OpenBSD: cissvar.h,v 1.15 2013/05/30 16:15:02 deraadt Exp $ */ /* * Copyright (c) 2005,2006 Michael Shalayeff @@ -31,7 +31,6 @@ struct ciss_softc { struct scsi_link sc_link; struct timeout sc_hb; void *sc_ih; - void *sc_sh; int sc_flush; struct ksensor *sensors; struct ksensordev sensordev; @@ -68,3 +67,4 @@ typedef int ciss_lock_t; int ciss_attach(struct ciss_softc *sc); int ciss_intr(void *v); +void ciss_shutdown(void *v); diff --git a/sys/dev/ic/dpt.c b/sys/dev/ic/dpt.c index 5f212a4dad6..feaddcf2494 100644 --- a/sys/dev/ic/dpt.c +++ b/sys/dev/ic/dpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dpt.c,v 1.33 2011/06/21 20:23:49 matthew Exp $ */ +/* $OpenBSD: dpt.c,v 1.34 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: dpt.c,v 1.12 1999/10/23 16:26:33 ad Exp $ */ /*- @@ -316,9 +316,6 @@ dpt_init(sc, intrstr) sc->sc_nccbs = i; } - /* Set shutdownhook before we start any device activity */ - sc->sc_sdh = shutdownhook_establish(dpt_shutdown, sc); - /* Get the page 0 inquiry data from the HBA */ dpt_hba_inquire(sc, &ei); @@ -384,20 +381,16 @@ dpt_init(sc, intrstr) } /* - * Our 'shutdownhook' to cleanly shut down the HBA. The HBA must flush + * Cleanly shut down the HBA. The HBA must flush * all data from its cache and mark array groups as clean. */ void -dpt_shutdown(xxx_sc) - void *xxx_sc; +dpt_shutdown(void *v) { - struct dpt_softc *sc; + struct dpt_softc *sc = v; - sc = xxx_sc; - printf("shutting down %s...", sc->sc_dv.dv_xname); dpt_cmd(sc, NULL, 0, CP_IMMEDIATE, CPI_POWEROFF_WARN); DELAY(5000*1000); - printf(" done\n"); } /* diff --git a/sys/dev/ic/dptvar.h b/sys/dev/ic/dptvar.h index 6731633e6f6..75cc60a94be 100644 --- a/sys/dev/ic/dptvar.h +++ b/sys/dev/ic/dptvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dptvar.h,v 1.10 2011/06/21 20:23:49 matthew Exp $ */ +/* $OpenBSD: dptvar.h,v 1.11 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: dptvar.h,v 1.5 1999/10/23 16:26:32 ad Exp $ */ /* @@ -69,7 +69,6 @@ struct dpt_softc { bus_dma_tag_t sc_dmat; /* bus DMA tag */ bus_dmamap_t sc_dmamap_ccb; /* maps the CCBs */ void *sc_ih; /* interrupt handler cookie */ - void *sc_sdh; /* shutdown hook */ struct dpt_ccb *sc_ccbs; /* all our CCBs */ struct eata_sp *sc_statpack; /* EATA status packet */ int sc_spoff; /* status packet offset in dmamap */ diff --git a/sys/dev/isa/fd.c b/sys/dev/isa/fd.c index 0d02c79a1f4..f7e8830537c 100644 --- a/sys/dev/isa/fd.c +++ b/sys/dev/isa/fd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fd.c,v 1.92 2011/07/04 05:41:48 matthew Exp $ */ +/* $OpenBSD: fd.c,v 1.93 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: fd.c,v 1.90 1996/05/12 23:12:03 mycroft Exp $ */ /*- @@ -117,8 +117,6 @@ struct fd_softc { #define FD_MOTOR_WAIT 0x04 /* motor coming up */ int sc_cylin; /* where we think the head is */ - void *sc_sdhook; /* saved shutdown hook for drive. */ - TAILQ_ENTRY(fd_softc) sc_drivechain; int sc_ops; /* I/O ops since last switch */ struct buf sc_q; /* head of buf chain */ @@ -130,9 +128,10 @@ struct fd_softc { /* floppy driver configuration */ int fdprobe(struct device *, void *, void *); void fdattach(struct device *, struct device *, void *); +int fdactivate(struct device *, int); struct cfattach fd_ca = { - sizeof(struct fd_softc), fdprobe, fdattach + sizeof(struct fd_softc), fdprobe, fdattach, NULL, fdactivate }; struct cfdriver fd_cd = { @@ -302,15 +301,26 @@ fdattach(struct device *parent, struct device *self, void *aux) fd->sc_dk.dk_name = fd->sc_dev.dv_xname; disk_attach(&fd->sc_dev, &fd->sc_dk); - /* Needed to power off if the motor is on when we halt. */ - fd->sc_sdhook = shutdownhook_establish(fd_motor_off, fd); - /* Setup timeout structures */ timeout_set(&fd->fd_motor_on_to, fd_motor_on, fd); timeout_set(&fd->fd_motor_off_to, fd_motor_off, fd); timeout_set(&fd->fdtimeout_to, fdtimeout, fd); } +int +fdactivate(struct device *self, int act) +{ + int rv = 0; + + switch (act) { + case DVACT_POWERDOWN: + fd_motor_off(self); + break; + } + + return (rv); +} + /* * Translate nvram type into internal data structure. Return NULL for * none/unknown/unusable. diff --git a/sys/dev/isa/isa.c b/sys/dev/isa/isa.c index 408e9f179dd..f817620e328 100644 --- a/sys/dev/isa/isa.c +++ b/sys/dev/isa/isa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isa.c,v 1.40 2010/07/08 20:18:32 deraadt Exp $ */ +/* $OpenBSD: isa.c,v 1.41 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: isa.c,v 1.85 1996/05/14 00:31:04 thorpej Exp $ */ /* @@ -75,8 +75,7 @@ void isaattach(struct device *, struct device *, void *); extern int autoconf_verbose; struct cfattach isa_ca = { - sizeof(struct isa_softc), isamatch, isaattach, NULL, - config_activate_children + sizeof(struct isa_softc), isamatch, isaattach }; struct cfdriver isa_cd = { diff --git a/sys/dev/pci/ahd_pci.c b/sys/dev/pci/ahd_pci.c index 6c89c339181..89dba9301bc 100644 --- a/sys/dev/pci/ahd_pci.c +++ b/sys/dev/pci/ahd_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ahd_pci.c,v 1.21 2012/12/05 23:20:19 deraadt Exp $ */ +/* $OpenBSD: ahd_pci.c,v 1.22 2013/05/30 16:15:02 deraadt Exp $ */ /* * Copyright (c) 2004 Milos Urbanek, Kenneth R. Westerback & Marco Peereboom @@ -283,9 +283,11 @@ static const char *pci_bus_modes[] = int ahd_pci_probe(struct device *, void *, void *); void ahd_pci_attach(struct device *, struct device *, void *); +int ahd_activate(struct device *, int); struct cfattach ahd_pci_ca = { - sizeof(struct ahd_softc), ahd_pci_probe, ahd_pci_attach + sizeof(struct ahd_softc), ahd_pci_probe, ahd_pci_attach, + NULL, ahd_activate }; int ahd_check_extport(struct ahd_softc *ahd); @@ -540,6 +542,22 @@ ahd_pci_attach(struct device *parent, struct device *self, void *aux) ahd_attach(ahd); } +int +ahd_activate(struct device *self, int act) +{ + int ret = 0; + + ret = config_activate_children(self, act); + + switch (act) { + case DVACT_POWERDOWN: + ahd_shutdown(self); + break; + } + + return (ret); +} + /* * Perform some simple tests that should catch situations where * our registers are invalidly mapped. diff --git a/sys/dev/pci/amdpm.c b/sys/dev/pci/amdpm.c index 81063f43fc0..6fea65c5247 100644 --- a/sys/dev/pci/amdpm.c +++ b/sys/dev/pci/amdpm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: amdpm.c,v 1.28 2012/10/05 10:51:28 haesbaert Exp $ */ +/* $OpenBSD: amdpm.c,v 1.29 2013/05/30 16:15:02 deraadt Exp $ */ /* * Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org> @@ -185,8 +185,8 @@ int amdpm_i2c_exec(void *, i2c_op_t, i2c_addr_t, const void *, size_t, int amdpm_intr(void *); struct cfattach amdpm_ca = { - sizeof(struct amdpm_softc), amdpm_match, amdpm_attach, NULL, - amdpm_activate + sizeof(struct amdpm_softc), amdpm_match, amdpm_attach, + NULL, amdpm_activate }; struct cfdriver amdpm_cd = { @@ -312,8 +312,15 @@ int amdpm_activate(struct device *self, int act) { struct amdpm_softc *sc = (struct amdpm_softc *)self; + int ret = 0; switch (act) { + case DVACT_QUIESCE: + ret = config_activate_children(self, act); + break; + case DVACT_SUSPEND: + ret = config_activate_children(self, act); + break; case DVACT_RESUME: if (timeout_initialized(&sc->sc_rnd_ch)) { pcireg_t cfg_reg; @@ -325,9 +332,13 @@ amdpm_activate(struct device *self, int act) AMDPM_CONFREG, cfg_reg | AMDPM_RNGEN); } + ret = config_activate_children(self, act); + break; + case DVACT_POWERDOWN: + ret = config_activate_children(self, act); break; } - return (0); + return (ret); } void diff --git a/sys/dev/pci/arc.c b/sys/dev/pci/arc.c index 67f55c1c8f7..639c6a425cb 100644 --- a/sys/dev/pci/arc.c +++ b/sys/dev/pci/arc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arc.c,v 1.95 2011/07/17 22:46:48 matthew Exp $ */ +/* $OpenBSD: arc.c,v 1.96 2013/05/30 16:15:02 deraadt Exp $ */ /* * Copyright (c) 2006 David Gwynne <dlg@openbsd.org> @@ -347,7 +347,7 @@ struct arc_fw_sysinfo { int arc_match(struct device *, void *, void *); void arc_attach(struct device *, struct device *, void *); int arc_detach(struct device *, int); -void arc_shutdown(void *); +int arc_activate(struct device *, int); int arc_intr(void *); struct arc_iop; @@ -369,8 +369,6 @@ struct arc_softc { void *sc_ih; - void *sc_shutdownhook; - int sc_req_count; struct arc_dmamem *sc_requests; @@ -393,7 +391,8 @@ struct arc_softc { #define DEVNAME(_s) ((_s)->sc_dev.dv_xname) struct cfattach arc_ca = { - sizeof(struct arc_softc), arc_match, arc_attach, arc_detach + sizeof(struct arc_softc), arc_match, arc_attach, arc_detach, + arc_activate }; struct cfdriver arc_cd = { @@ -590,10 +589,6 @@ arc_attach(struct device *parent, struct device *self, void *aux) goto unmap_pci; } - sc->sc_shutdownhook = shutdownhook_establish(arc_shutdown, sc); - if (sc->sc_shutdownhook == NULL) - panic("unable to establish arc shutdownhook"); - sc->sc_link.adapter = &arc_switch; sc->sc_link.adapter_softc = sc; sc->sc_link.adapter_target = ARC_MAX_TARGET; @@ -633,31 +628,40 @@ unmap_pci: } int -arc_detach(struct device *self, int flags) +arc_activate(struct device *self, int act) { - struct arc_softc *sc = (struct arc_softc *)self; - - shutdownhook_disestablish(sc->sc_shutdownhook); - - if (arc_msg0(sc, ARC_RA_INB_MSG0_STOP_BGRB) != 0) - printf("%s: timeout waiting to stop bg rebuild\n", DEVNAME(sc)); - - if (arc_msg0(sc, ARC_RA_INB_MSG0_FLUSH_CACHE) != 0) - printf("%s: timeout waiting to flush cache\n", DEVNAME(sc)); + int ret = 0; - return (0); + switch (act) { + case DVACT_QUIESCE: + ret = config_activate_children(self, act); + break; + case DVACT_SUSPEND: + ret = config_activate_children(self, act); + break; + case DVACT_POWERDOWN: + ret = config_activate_children(self, act); + arc_detach(self, 0); + break; + case DVACT_RESUME: + ret = config_activate_children(self, act); + break; + } + return (ret); } -void -arc_shutdown(void *xsc) +int +arc_detach(struct device *self, int flags) { - struct arc_softc *sc = xsc; + struct arc_softc *sc = (struct arc_softc *)self; if (arc_msg0(sc, ARC_RA_INB_MSG0_STOP_BGRB) != 0) printf("%s: timeout waiting to stop bg rebuild\n", DEVNAME(sc)); if (arc_msg0(sc, ARC_RA_INB_MSG0_FLUSH_CACHE) != 0) printf("%s: timeout waiting to flush cache\n", DEVNAME(sc)); + + return (0); } int diff --git a/sys/dev/pci/azalia.c b/sys/dev/pci/azalia.c index a9668679380..5cfc8eb80a1 100644 --- a/sys/dev/pci/azalia.c +++ b/sys/dev/pci/azalia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: azalia.c,v 1.205 2013/05/24 07:58:46 ratchov Exp $ */ +/* $OpenBSD: azalia.c,v 1.206 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: azalia.c,v 1.20 2006/05/07 08:31:44 kent Exp $ */ /*- @@ -550,8 +550,6 @@ azalia_pci_attach(struct device *parent, struct device *self, void *aux) sc->audiodev = audio_attach_mi(&azalia_hw_if, sc, &sc->dev); - shutdownhook_establish(azalia_shutdown, sc); - return; err_exit: @@ -572,6 +570,9 @@ azalia_pci_activate(struct device *self, int act) case DVACT_SUSPEND: azalia_suspend(sc); break; + case DVACT_POWERDOWN: + azalia_shutdown(sc); + break; case DVACT_RESUME: azalia_resume(sc); rv = config_activate_children(self, act); diff --git a/sys/dev/pci/cac_pci.c b/sys/dev/pci/cac_pci.c index 4304deabca2..144cfe5a888 100644 --- a/sys/dev/pci/cac_pci.c +++ b/sys/dev/pci/cac_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cac_pci.c,v 1.13 2009/04/06 15:18:45 kettenis Exp $ */ +/* $OpenBSD: cac_pci.c,v 1.14 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: cac_pci.c,v 1.10 2001/01/10 16:48:04 ad Exp $ */ /*- @@ -56,6 +56,7 @@ void cac_pci_attach(struct device *, struct device *, void *); const struct cac_pci_type *cac_pci_findtype(struct pci_attach_args *); int cac_pci_match(struct device *, void *, void *); +int cac_activate(struct device *, int); struct cac_ccb *cac_pci_l0_completed(struct cac_softc *); int cac_pci_l0_fifo_full(struct cac_softc *); @@ -233,6 +234,24 @@ cac_pci_attach(parent, self, aux) cac_init(sc, (ct->ct_flags & CT_STARTFW) != 0); } +int +cac_activate(struct device *self, int act) +{ + struct cac_softc *sc = (struct cac_softc *)self; + int ret = 0; + + ret = config_activate_children(self, act); + + switch (act) { + case DVACT_POWERDOWN: + cac_flush(sc); + break; + } + + return (ret); +} + + void cac_pci_l0_submit(struct cac_softc *sc, struct cac_ccb *ccb) { diff --git a/sys/dev/pci/ciss_pci.c b/sys/dev/pci/ciss_pci.c index cd452b77d8e..3c6d58c0324 100644 --- a/sys/dev/pci/ciss_pci.c +++ b/sys/dev/pci/ciss_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ciss_pci.c,v 1.16 2012/03/11 13:33:06 jsg Exp $ */ +/* $OpenBSD: ciss_pci.c,v 1.17 2013/05/30 16:15:02 deraadt Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -39,9 +39,11 @@ int ciss_pci_match(struct device *, void *, void *); void ciss_pci_attach(struct device *, struct device *, void *); +int ciss_activate(struct device *, int); struct cfattach ciss_pci_ca = { - sizeof(struct ciss_softc), ciss_pci_match, ciss_pci_attach + sizeof(struct ciss_softc), ciss_pci_match, ciss_pci_attach, + NULL, ciss_activate }; const struct pci_matchid ciss_pci_devices[] = { @@ -192,3 +194,19 @@ ciss_pci_attach(struct device *parent, struct device *self, void *aux) bus_space_write_4(sc->iot, sc->ioh, CISS_IMR, bus_space_read_4(sc->iot, sc->ioh, CISS_IMR) & ~sc->iem); } + +int +ciss_activate(struct device *self, int act) +{ + int ret = 0; + + ret = config_activate_children(self, act); + + switch (act) { + case DVACT_POWERDOWN: + ciss_shutdown(self); + break; + } + + return (ret); +} diff --git a/sys/dev/pci/dpt_pci.c b/sys/dev/pci/dpt_pci.c index b1bb1666f89..6434a29a9f7 100644 --- a/sys/dev/pci/dpt_pci.c +++ b/sys/dev/pci/dpt_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dpt_pci.c,v 1.6 2008/05/13 02:24:08 brad Exp $ */ +/* $OpenBSD: dpt_pci.c,v 1.7 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: dpt_pci.c,v 1.2 1999/09/29 17:33:02 ad Exp $ */ /* @@ -68,9 +68,11 @@ int dpt_pci_match(struct device *, struct cfdata *, void *); int dpt_pci_match(struct device *, void *, void *); #endif /* __OpenBSD__ */ void dpt_pci_attach(struct device *, struct device *, void *); +int dpt_activate(struct device *, int); struct cfattach dpt_pci_ca = { - sizeof(struct dpt_softc), dpt_pci_match, dpt_pci_attach + sizeof(struct dpt_softc), dpt_pci_match, dpt_pci_attach, NULL, + dpt_activate }; int @@ -149,3 +151,27 @@ dpt_pci_attach(parent, self, aux) /* Now attach to the bus-independant code */ dpt_init(sc, intrstr); } + +int +dpt_activate(struct device *self, int act) +{ + int ret = 0; + + switch (act) { + case DVACT_QUIESCE: + ret = config_activate_children(self, act); + break; + case DVACT_SUSPEND: + ret = config_activate_children(self, act); + break; + case DVACT_POWERDOWN: + ret = config_activate_children(self, act); + dpt_shutdown(self); + break; + case DVACT_RESUME: + ret = config_activate_children(self, act); + break; + } + + return (ret); +} diff --git a/sys/dev/pci/iop_pci.c b/sys/dev/pci/iop_pci.c index f0b70f06fbf..a92ca464b87 100644 --- a/sys/dev/pci/iop_pci.c +++ b/sys/dev/pci/iop_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iop_pci.c,v 1.8 2010/07/13 13:07:35 kettenis Exp $ */ +/* $OpenBSD: iop_pci.c,v 1.9 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: iop_pci.c,v 1.4 2001/03/20 13:21:00 ad Exp $ */ /*- @@ -56,9 +56,11 @@ void iop_pci_attach(struct device *, struct device *, void *); int iop_pci_match(struct device *, void *, void *); +int iop_activate(struct device *, int); struct cfattach iop_pci_ca = { - sizeof(struct iop_softc), iop_pci_match, iop_pci_attach + sizeof(struct iop_softc), iop_pci_match, iop_pci_attach, + NULL, iop_activate }; int @@ -143,3 +145,27 @@ iop_pci_attach(struct device *parent, struct device *self, void *aux) /* Attach to the bus-independent code. */ iop_init(sc, intrstr); } + +int +iop_activate(struct device *self, int act) +{ + int ret = 0; + + switch (act) { + case DVACT_QUIESCE: + ret = config_activate_children(self, act); + break; + case DVACT_SUSPEND: + ret = config_activate_children(self, act); + break; + case DVACT_POWERDOWN: + ret = config_activate_children(self, act); + iop_shutdown(self); + break; + case DVACT_RESUME: + ret = config_activate_children(self, act); + break; + } + + return (ret); +} diff --git a/sys/dev/pci/puc.c b/sys/dev/pci/puc.c index f52c0dabe31..ab845fb8562 100644 --- a/sys/dev/pci/puc.c +++ b/sys/dev/pci/puc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: puc.c,v 1.22 2012/06/12 18:43:26 kettenis Exp $ */ +/* $OpenBSD: puc.c,v 1.23 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: puc.c,v 1.3 1999/02/06 06:29:54 cgd Exp $ */ /* @@ -83,7 +83,7 @@ void *puc_pci_intr_establish(struct puc_attach_args *, int, struct cfattach puc_pci_ca = { sizeof(struct puc_pci_softc), puc_pci_match, - puc_pci_attach, puc_pci_detach, config_activate_children + puc_pci_attach, puc_pci_detach }; struct cfdriver puc_cd = { diff --git a/sys/dev/pci/tcpcib.c b/sys/dev/pci/tcpcib.c index 3f8386c78db..0b6f93d56a3 100644 --- a/sys/dev/pci/tcpcib.c +++ b/sys/dev/pci/tcpcib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcpcib.c,v 1.4 2012/10/17 22:32:01 deraadt Exp $ */ +/* $OpenBSD: tcpcib.c,v 1.5 2013/05/30 16:15:02 deraadt Exp $ */ /* * Copyright (c) 2012 Matt Dainty <matt@bodgit-n-scarper.com> @@ -269,9 +269,11 @@ int tcpcib_activate(struct device *self, int act) { struct tcpcib_softc *sc = (struct tcpcib_softc *)self; - + int ret = 0; + switch (act) { case DVACT_SUSPEND: + ret = config_activate_children(self, act); /* Watchdog is running, disable it */ if (sc->sc_active & E600_WDT_ACTIVE && sc->sc_wdt_period != 0) tcpcib_wdt_stop(sc); @@ -291,9 +293,13 @@ tcpcib_activate(struct device *self, int act) if (sc->sc_active & E600_HPET_ACTIVE) bus_space_write_4(sc->sc_hpet_iot, sc->sc_hpet_ioh, E600_HPET_GC, E600_HPET_GC_ENABLE); + ret = config_activate_children(self, act); + break; + default: + ret = config_activate_children(self, act); break; } - return (0); + return (ret); } int diff --git a/sys/dev/pcmcia/cfxga.c b/sys/dev/pcmcia/cfxga.c index acf73b5bc95..952ae0fec38 100644 --- a/sys/dev/pcmcia/cfxga.c +++ b/sys/dev/pcmcia/cfxga.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cfxga.c,v 1.21 2011/07/03 15:47:17 matthew Exp $ */ +/* $OpenBSD: cfxga.c,v 1.22 2013/05/30 16:15:02 deraadt Exp $ */ /* * Copyright (c) 2005, 2006, Matthieu Herrb and Miodrag Vallat @@ -316,13 +316,16 @@ int cfxga_activate(struct device *dev, int act) { struct cfxga_softc *sc = (void *)dev; + int ret = 0; switch (act) { case DVACT_DEACTIVATE: pcmcia_function_disable(sc->sc_pf); break; + case DVACT_POWERDOWN: + ret = config_activate_children(self, act); } - return (0); + return (ret); } void diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c index 57f30ca7506..948be507f4a 100644 --- a/sys/dev/usb/ehci.c +++ b/sys/dev/usb/ehci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ehci.c,v 1.132 2013/05/20 08:19:47 yasuoka Exp $ */ +/* $OpenBSD: ehci.c,v 1.133 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: ehci.c,v 1.66 2004/06/30 03:11:56 mycroft Exp $ */ /* @@ -1053,6 +1053,7 @@ ehci_activate(struct device *self, int act) rv = config_activate_children(self, act); break; case DVACT_SUSPEND: + rv = config_activate_children(self, act); sc->sc_bus.use_polling++; for (i = 1; i <= sc->sc_noport; i++) { @@ -1095,6 +1096,7 @@ ehci_activate(struct device *self, int act) sc->sc_bus.use_polling--; break; case DVACT_POWERDOWN: + rv = config_activate_children(self, act); ehci_shutdown(sc); break; case DVACT_RESUME: diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c index 87770263d74..4b2074cf7a2 100644 --- a/sys/dev/usb/ohci.c +++ b/sys/dev/usb/ohci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ohci.c,v 1.112 2013/05/20 08:19:47 yasuoka Exp $ */ +/* $OpenBSD: ohci.c,v 1.113 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: ohci.c,v 1.139 2003/02/22 05:24:16 tsutsui Exp $ */ /* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */ @@ -99,7 +99,6 @@ usbd_status ohci_alloc_std_chain(struct ohci_pipe *, struct ohci_softc *, u_int, int, struct usbd_xfer *, struct ohci_soft_td *, struct ohci_soft_td **); -void ohci_shutdown(void *v); usbd_status ohci_open(struct usbd_pipe *); void ohci_poll(struct usbd_bus *); void ohci_softintr(void *); @@ -325,6 +324,7 @@ ohci_activate(struct device *self, int act) switch (act) { case DVACT_SUSPEND: + rv = config_activate_children(self, act); sc->sc_bus.use_polling++; reg = OREAD4(sc, OHCI_CONTROL) & ~OHCI_HCFS_MASK; if (sc->sc_control == 0) { @@ -342,6 +342,10 @@ ohci_activate(struct device *self, int act) usb_delay_ms(&sc->sc_bus, USB_RESUME_WAIT); sc->sc_bus.use_polling--; break; + case DVACT_POWERDOWN: + rv = config_activate_children(self, act); + OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET); + break; case DVACT_RESUME: sc->sc_bus.use_polling++; @@ -377,6 +381,7 @@ ohci_activate(struct device *self, int act) usb_delay_ms(&sc->sc_bus, USB_RESUME_RECOVERY); sc->sc_control = sc->sc_intre = sc->sc_ival = 0; sc->sc_bus.use_polling--; + rv = config_activate_children(self, act); break; case DVACT_DEACTIVATE: if (sc->sc_child != NULL) @@ -400,9 +405,6 @@ ohci_detach(struct ohci_softc *sc, int flags) timeout_del(&sc->sc_tmo_rhsc); - if (sc->sc_shutdownhook != NULL) - shutdownhook_disestablish(sc->sc_shutdownhook); - usb_delay_ms(&sc->sc_bus, 300); /* XXX let stray task complete */ /* free data structures XXX */ @@ -919,7 +921,6 @@ ohci_init(struct ohci_softc *sc) sc->sc_bus.pipe_size = sizeof(struct ohci_pipe); sc->sc_control = sc->sc_intre = 0; - sc->sc_shutdownhook = shutdownhook_establish(ohci_shutdown, sc); timeout_set(&sc->sc_tmo_rhsc, ohci_rhsc_enable, sc); @@ -986,18 +987,6 @@ ohci_freex(struct usbd_bus *bus, struct usbd_xfer *xfer) SIMPLEQ_INSERT_HEAD(&sc->sc_free_xfers, xfer, next); } -/* - * Shut down the controller when the system is going down. - */ -void -ohci_shutdown(void *v) -{ - struct ohci_softc *sc = v; - - DPRINTF(("ohci_shutdown: stopping the HC\n")); - OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET); -} - #ifdef OHCI_DEBUG void ohci_dumpregs(struct ohci_softc *sc) diff --git a/sys/dev/usb/ohcivar.h b/sys/dev/usb/ohcivar.h index e1b6123f106..75eed0dc095 100644 --- a/sys/dev/usb/ohcivar.h +++ b/sys/dev/usb/ohcivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ohcivar.h,v 1.32 2013/04/15 09:23:01 mglocker Exp $ */ +/* $OpenBSD: ohcivar.h,v 1.33 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: ohcivar.h,v 1.32 2003/02/22 05:24:17 tsutsui Exp $ */ /* $FreeBSD: src/sys/dev/usb/ohcivar.h,v 1.13 1999/11/17 22:33:41 n_hibma Exp $ */ @@ -116,8 +116,6 @@ struct ohci_softc { char sc_vendor[16]; int sc_id_vendor; - void *sc_shutdownhook; /* cookie from shutdown hook */ - u_int32_t sc_control; /* Preserved during suspend/standby */ u_int32_t sc_intre; u_int32_t sc_ival; diff --git a/sys/dev/usb/udl.c b/sys/dev/usb/udl.c index 8423850539b..b392b804804 100644 --- a/sys/dev/usb/udl.c +++ b/sys/dev/usb/udl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udl.c,v 1.75 2013/04/26 14:28:39 mpi Exp $ */ +/* $OpenBSD: udl.c,v 1.76 2013/05/30 16:15:02 deraadt Exp $ */ /* * Copyright (c) 2009 Marcus Glocker <mglocker@openbsd.org> @@ -486,14 +486,16 @@ int udl_activate(struct device *self, int act) { struct udl_softc *sc = (struct udl_softc *)self; + int ret = 0; switch (act) { case DVACT_DEACTIVATE: usbd_deactivate(sc->sc_udev); break; } + ret = config_activate_children(self, act); - return (0); + return (ret); } /* ---------- */ diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c index 487fda3922d..d2168f094ce 100644 --- a/sys/dev/usb/uhci.c +++ b/sys/dev/usb/uhci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhci.c,v 1.97 2013/05/20 08:19:47 yasuoka Exp $ */ +/* $OpenBSD: uhci.c,v 1.98 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: uhci.c,v 1.172 2003/02/23 04:19:26 simonb Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */ @@ -127,7 +127,6 @@ struct uhci_pipe { void uhci_globalreset(struct uhci_softc *); usbd_status uhci_portreset(struct uhci_softc *, int); void uhci_reset(struct uhci_softc *); -void uhci_shutdown(void *v); usbd_status uhci_run(struct uhci_softc *, int run); struct uhci_soft_td *uhci_alloc_std(struct uhci_softc *); void uhci_free_std(struct uhci_softc *, struct uhci_soft_td *); @@ -502,7 +501,6 @@ uhci_init(struct uhci_softc *sc) sc->sc_bus.pipe_size = sizeof(struct uhci_pipe); sc->sc_suspend = DVACT_RESUME; - sc->sc_shutdownhook = shutdownhook_establish(uhci_shutdown, sc); UHCICMD(sc, UHCI_CMD_MAXP); /* Assume 64 byte packets at frame end */ @@ -525,6 +523,7 @@ uhci_activate(struct device *self, int act) if (uhcidebug > 2) uhci_dumpregs(sc); #endif + rv = config_activate_children(self, act); if (sc->sc_intr_xfer != NULL) timeout_del(&sc->sc_poll_handle); sc->sc_bus.use_polling++; @@ -542,6 +541,10 @@ uhci_activate(struct device *self, int act) sc->sc_bus.use_polling--; DPRINTF(("uhci_activate: cmd=0x%x\n", UREAD2(sc, UHCI_CMD))); break; + case DVACT_POWERDOWN: + rv = config_activate_children(self, act); + uhci_run(sc, 0); /* stop the controller */ + break; case DVACT_RESUME: #ifdef DIAGNOSTIC if (sc->sc_suspend == DVACT_RESUME) @@ -577,6 +580,7 @@ uhci_activate(struct device *self, int act) if (uhcidebug > 2) uhci_dumpregs(sc); #endif + rv = config_activate_children(self, act); break; case DVACT_DEACTIVATE: if (sc->sc_child != NULL) @@ -598,9 +602,6 @@ uhci_detach(struct uhci_softc *sc, int flags) if (rv != 0) return (rv); - if (sc->sc_shutdownhook != NULL) - shutdownhook_disestablish(sc->sc_shutdownhook); - if (sc->sc_intr_xfer != NULL) { timeout_del(&sc->sc_poll_handle); sc->sc_intr_xfer = NULL; @@ -669,18 +670,6 @@ uhci_freex(struct usbd_bus *bus, struct usbd_xfer *xfer) SIMPLEQ_INSERT_HEAD(&sc->sc_free_xfers, xfer, next); } -/* - * Shut down the controller when the system is going down. - */ -void -uhci_shutdown(void *v) -{ - struct uhci_softc *sc = v; - - DPRINTF(("uhci_shutdown: stopping the HC\n")); - uhci_run(sc, 0); /* stop the controller */ -} - #ifdef UHCI_DEBUG void uhci_dumpregs(struct uhci_softc *sc) diff --git a/sys/dev/usb/uhcivar.h b/sys/dev/usb/uhcivar.h index 09e71b715c5..9205b58d639 100644 --- a/sys/dev/usb/uhcivar.h +++ b/sys/dev/usb/uhcivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uhcivar.h,v 1.25 2013/04/15 09:23:02 mglocker Exp $ */ +/* $OpenBSD: uhcivar.h,v 1.26 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: uhcivar.h,v 1.36 2002/12/31 00:39:11 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhcivar.h,v 1.14 1999/11/17 22:33:42 n_hibma Exp $ */ @@ -170,8 +170,6 @@ struct uhci_softc { char sc_vendor[32]; /* vendor string for root hub */ int sc_id_vendor; /* vendor ID for root hub */ - void *sc_shutdownhook; /* cookie from shutdown hook */ - struct device *sc_child; /* /dev/usb# device */ }; diff --git a/sys/dev/usb/umass.c b/sys/dev/usb/umass.c index a25fc2aa44a..1502bb2cbb7 100644 --- a/sys/dev/usb/umass.c +++ b/sys/dev/usb/umass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umass.c,v 1.63 2013/04/15 09:23:02 mglocker Exp $ */ +/* $OpenBSD: umass.c,v 1.64 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: umass.c,v 1.116 2004/06/30 05:53:46 mycroft Exp $ */ /* @@ -687,6 +687,9 @@ umass_activate(struct device *dev, int act) DPRINTF(UDMASS_USB, ("%s: umass_activate: child " "returned %d\n", sc->sc_dev.dv_xname, rv)); break; + default: + rv = config_activate_children(dev, act); + break; } return (rv); } diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c index 2054f207820..affda3e7c36 100644 --- a/sys/dev/usb/usb.c +++ b/sys/dev/usb/usb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usb.c,v 1.91 2013/05/17 09:09:11 mpi Exp $ */ +/* $OpenBSD: usb.c,v 1.92 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: usb.c,v 1.77 2003/01/01 00:10:26 thorpej Exp $ */ /* @@ -881,6 +881,13 @@ usb_activate(struct device *self, int act) } } break; + case DVACT_QUIESCE: + rv = config_activate_children(self, act); + break; + case DVACT_SUSPEND: + break; + case DVACT_POWERDOWN: + break; case DVACT_RESUME: usb_needs_explore(sc->sc_bus->root_hub, 0); break; diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c index 49e91859a9e..00b1475fe2e 100644 --- a/sys/dev/wscons/wsdisplay.c +++ b/sys/dev/wscons/wsdisplay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsdisplay.c,v 1.108 2013/05/12 20:41:45 kettenis Exp $ */ +/* $OpenBSD: wsdisplay.c,v 1.109 2013/05/30 16:15:02 deraadt Exp $ */ /* $NetBSD: wsdisplay.c,v 1.82 2005/02/27 00:27:52 perry Exp $ */ /* @@ -156,7 +156,6 @@ int wsdisplay_getscreen(struct wsdisplay_softc *, struct wsdisplay_addscreendata *); void wsdisplay_resume_device(struct device *); void wsdisplay_suspend_device(struct device *); -void wsdisplay_shutdownhook(void *); void wsdisplay_addscreen_print(struct wsdisplay_softc *, int, int); void wsdisplay_closescreen(struct wsdisplay_softc *, struct wsscreen *); int wsdisplay_delscreen(struct wsdisplay_softc *, int, int); @@ -216,13 +215,15 @@ int wsdisplay_emul_match(struct device *, void *, void *); void wsdisplay_emul_attach(struct device *, struct device *, void *); int wsdisplay_emul_detach(struct device *, int); +int wsdisplay_activate(struct device *, int); + struct cfdriver wsdisplay_cd = { NULL, "wsdisplay", DV_TTY }; struct cfattach wsdisplay_emul_ca = { sizeof(struct wsdisplay_softc), wsdisplay_emul_match, - wsdisplay_emul_attach, wsdisplay_emul_detach + wsdisplay_emul_attach, wsdisplay_emul_detach, wsdisplay_activate }; void wsdisplaystart(struct tty *); @@ -585,6 +586,20 @@ wsdisplay_emul_detach(struct device *self, int flags) } int +wsdisplay_activate(struct device *self, int act) +{ + int ret = 0; + + switch (act) { + case DVACT_POWERDOWN: + wsdisplay_switchtoconsole(); + break; + } + + return (ret); +} + +int wsdisplay_common_detach(struct wsdisplay_softc *sc, int flags) { int i; @@ -659,7 +674,6 @@ wsdisplay_common_attach(struct wsdisplay_softc *sc, int console, int kbdmux, const struct wsdisplay_accessops *accessops, void *accesscookie, u_int defaultscreens) { - static int hookset = 0; int i, start = 0; #if NWSKBD > 0 struct wsevsrc *kme; @@ -754,10 +768,6 @@ wsdisplay_common_attach(struct wsdisplay_softc *sc, int console, int kbdmux, wsdisplay_burn(sc, sc->sc_burnflags); #endif - if (hookset == 0) - shutdownhook_establish(wsdisplay_shutdownhook, NULL); - hookset = 1; - #if NWSKBD > 0 && NWSMUX == 0 if (console == 0) { /* @@ -2353,15 +2363,6 @@ wsdisplay_burner(void *v) } #endif -/* - * Switch the console at shutdown. - */ -void -wsdisplay_shutdownhook(void *arg) -{ - wsdisplay_switchtoconsole(); -} - #ifdef WSMOUSED_SUPPORT /* * wsmoused(8) support functions |