summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMike Belopuhov <mikeb@cvs.openbsd.org>2014-12-10 12:27:58 +0000
committerMike Belopuhov <mikeb@cvs.openbsd.org>2014-12-10 12:27:58 +0000
commit9ce9e30960b2e6222a244e6166aea039ac6e9239 (patch)
tree212abc4dfaf05d91acce75be7ded7a8eac5e95e7 /sys
parent77392a36ec6c525667e826c787c431b014f99298 (diff)
Convert watchdog(4) devices to use autoconf(9) framework.
ok deraadt, tests on glxpcib and ok mpi
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/armv7/omap/omdog.c19
-rw-r--r--sys/arch/armv7/sunxi/sxidog.c6
-rw-r--r--sys/arch/i386/i386/esm.c18
-rw-r--r--sys/arch/i386/pci/elan520.c18
-rw-r--r--sys/arch/i386/pci/geodesc.c20
-rw-r--r--sys/arch/sgi/localbus/imc.c22
-rw-r--r--sys/arch/sparc64/dev/lom.c3
-rw-r--r--sys/arch/sparc64/dev/pmc.c17
-rw-r--r--sys/dev/ipmi.c18
-rw-r--r--sys/dev/isa/fins.c19
-rw-r--r--sys/dev/isa/it.c19
-rw-r--r--sys/dev/isa/sch311x.c19
-rw-r--r--sys/dev/isa/viasio.c19
-rw-r--r--sys/dev/pci/berkwdt.c18
-rw-r--r--sys/dev/pci/glxpcib.c9
-rw-r--r--sys/dev/pci/ichwdt.c19
-rw-r--r--sys/dev/pci/pwdog.c18
-rw-r--r--sys/dev/pci/tcpcib.c7
-rw-r--r--sys/dev/pci/wdt.c18
-rw-r--r--sys/kern/kern_watchdog.c17
-rw-r--r--sys/sys/systm.h4
21 files changed, 277 insertions, 50 deletions
diff --git a/sys/arch/armv7/omap/omdog.c b/sys/arch/armv7/omap/omdog.c
index a8fb5d4855d..d3d54a5e073 100644
--- a/sys/arch/armv7/omap/omdog.c
+++ b/sys/arch/armv7/omap/omdog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: omdog.c,v 1.4 2014/11/01 07:08:43 jsg Exp $ */
+/* $OpenBSD: omdog.c,v 1.5 2014/12/10 12:27:56 mikeb Exp $ */
/*
* Copyright (c) 2013 Federico G. Schwindt <fgsch@openbsd.org>
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
@@ -57,6 +57,7 @@ struct omdog_softc {
struct omdog_softc *omdog_sc;
void omdog_attach(struct device *, struct device *, void *);
+int omdog_activate(struct device *, int);
void omdog_start(struct omdog_softc *);
void omdog_stop(struct omdog_softc *);
void omdog_sync(struct omdog_softc *);
@@ -64,7 +65,7 @@ int omdog_cb(void *, int);
void omdog_reset(void);
struct cfattach omdog_ca = {
- sizeof (struct omdog_softc), NULL, omdog_attach
+ sizeof (struct omdog_softc), NULL, omdog_attach, NULL, omdog_activate
};
struct cfdriver omdog_cd = {
@@ -95,6 +96,20 @@ omdog_attach(struct device *parent, struct device *self, void *args)
#endif
}
+int
+omdog_activate(struct device *self, int act)
+{
+ switch (act) {
+ case DVACT_POWERDOWN:
+#ifndef SMALL_KERNEL
+ wdog_shutdown(self);
+#endif
+ break;
+ }
+
+ return (0);
+}
+
void
omdog_start(struct omdog_softc *sc)
{
diff --git a/sys/arch/armv7/sunxi/sxidog.c b/sys/arch/armv7/sunxi/sxidog.c
index ab327ddb6fb..66a359f9cf5 100644
--- a/sys/arch/armv7/sunxi/sxidog.c
+++ b/sys/arch/armv7/sunxi/sxidog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sxidog.c,v 1.4 2014/11/01 07:08:43 jsg Exp $ */
+/* $OpenBSD: sxidog.c,v 1.5 2014/12/10 12:27:56 mikeb Exp $ */
/*
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
*
@@ -66,6 +66,7 @@ struct sxidog_softc {
struct sxidog_softc *sxidog_sc = NULL; /* for sxidog_reset() */
void sxidog_attach(struct device *, struct device *, void *);
+int sxidog_activate(struct device *, int);
int sxidog_callback(void *, int);
#if 0
int sxidog_intr(void *);
@@ -73,7 +74,8 @@ int sxidog_intr(void *);
void sxidog_reset(void);
struct cfattach sxidog_ca = {
- sizeof (struct sxidog_softc), NULL, sxidog_attach
+ sizeof (struct sxidog_softc), NULL, sxidog_attach,
+ NULL, sxidog_activate
};
struct cfdriver sxidog_cd = {
diff --git a/sys/arch/i386/i386/esm.c b/sys/arch/i386/i386/esm.c
index 54f9f6dd8e1..0f3e9f1fc43 100644
--- a/sys/arch/i386/i386/esm.c
+++ b/sys/arch/i386/i386/esm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: esm.c,v 1.56 2014/09/14 14:17:23 jsg Exp $ */
+/* $OpenBSD: esm.c,v 1.57 2014/12/10 12:27:56 mikeb Exp $ */
/*
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -45,6 +45,7 @@ int esmdebug = 3;
int esm_match(struct device *, void *, void *);
void esm_attach(struct device *, struct device *, void *);
+int esm_activate(struct device *, int);
enum esm_sensor_type {
ESM_S_UNKNOWN, /* XXX */
@@ -124,7 +125,8 @@ struct esm_softc {
};
struct cfattach esm_ca = {
- sizeof(struct esm_softc), esm_match, esm_attach
+ sizeof(struct esm_softc), esm_match, esm_attach,
+ NULL, esm_activate
};
struct cfdriver esm_cd = {
@@ -274,6 +276,18 @@ esm_attach(struct device *parent, struct device *self, void *aux)
}
int
+esm_activate(struct device *self, int act)
+{
+ switch (act) {
+ case DVACT_POWERDOWN:
+ wdog_shutdown(self);
+ break;
+ }
+
+ return (0);
+}
+
+int
esm_watchdog(void *arg, int period)
{
struct esm_softc *sc = arg;
diff --git a/sys/arch/i386/pci/elan520.c b/sys/arch/i386/pci/elan520.c
index bf077dd7c43..c6fdf943de5 100644
--- a/sys/arch/i386/pci/elan520.c
+++ b/sys/arch/i386/pci/elan520.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: elan520.c,v 1.20 2014/09/14 14:17:23 jsg Exp $ */
+/* $OpenBSD: elan520.c,v 1.21 2014/12/10 12:27:56 mikeb Exp $ */
/* $NetBSD: elan520.c,v 1.4 2002/10/02 05:47:15 thorpej Exp $ */
/*-
@@ -70,6 +70,7 @@ struct elansc_softc {
int elansc_match(struct device *, void *, void *);
void elansc_attach(struct device *, struct device *, void *);
+int elansc_activate(struct device *, int);
void elansc_update_cpuspeed(void);
void elansc_setperf(int);
int elansc_cpuspeed(int *);
@@ -86,7 +87,8 @@ void elansc_gpio_pin_ctl(void *, int, int);
u_int elansc_tc_read(struct timecounter *);
struct cfattach elansc_ca = {
- sizeof(struct elansc_softc), elansc_match, elansc_attach
+ sizeof(struct elansc_softc), elansc_match, elansc_attach,
+ NULL, elansc_activate
};
struct cfdriver elansc_cd = {
@@ -231,6 +233,18 @@ elansc_attach(struct device *parent, struct device *self, void *aux)
tc_init(tc);
}
+int
+elansc_activate(struct device *self, int act)
+{
+ switch (act) {
+ case DVACT_POWERDOWN:
+ wdog_shutdown(self);
+ break;
+ }
+
+ return (0);
+}
+
u_int
elansc_tc_read(struct timecounter *tc)
{
diff --git a/sys/arch/i386/pci/geodesc.c b/sys/arch/i386/pci/geodesc.c
index b903ece0fc5..53415de9816 100644
--- a/sys/arch/i386/pci/geodesc.c
+++ b/sys/arch/i386/pci/geodesc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: geodesc.c,v 1.12 2012/12/05 23:20:12 deraadt Exp $ */
+/* $OpenBSD: geodesc.c,v 1.13 2014/12/10 12:27:56 mikeb Exp $ */
/*
* Copyright (c) 2003 Markus Friedl <markus@openbsd.org>
@@ -41,6 +41,7 @@ struct geodesc_softc {
int geodesc_match(struct device *, void *, void *);
void geodesc_attach(struct device *, struct device *, void *);
+int geodesc_activate(struct device *, int);
void sc1100_sysreset(void);
#ifndef SMALL_KERNEL
@@ -48,7 +49,8 @@ int geodesc_wdogctl_cb(void *, int);
#endif /* SMALL_KERNEL */
struct cfattach geodesc_ca = {
- sizeof(struct geodesc_softc), geodesc_match, geodesc_attach
+ sizeof(struct geodesc_softc), geodesc_match, geodesc_attach,
+ NULL, geodesc_activate
};
struct cfdriver geodesc_cd = {
@@ -131,6 +133,20 @@ geodesc_attach(struct device *parent, struct device *self, void *aux)
cpuresetfn = sc1100_sysreset;
}
+int
+geodesc_activate(struct device *self, int act)
+{
+ switch (act) {
+ case DVACT_POWERDOWN:
+#ifndef SMALL_KERNEL
+ wdog_shutdown(self);
+#endif
+ break;
+ }
+
+ return (0);
+}
+
#ifndef SMALL_KERNEL
int
geodesc_wdogctl_cb(void *self, int period)
diff --git a/sys/arch/sgi/localbus/imc.c b/sys/arch/sgi/localbus/imc.c
index 13820743776..367b9277e87 100644
--- a/sys/arch/sgi/localbus/imc.c
+++ b/sys/arch/sgi/localbus/imc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imc.c,v 1.18 2014/10/08 05:22:48 deraadt Exp $ */
+/* $OpenBSD: imc.c,v 1.19 2014/12/10 12:27:56 mikeb Exp $ */
/* $NetBSD: imc.c,v 1.32 2011/07/01 18:53:46 dyoung Exp $ */
/*
@@ -75,10 +75,11 @@
int imc_match(struct device *, void *, void *);
void imc_attach(struct device *, struct device *, void *);
+int imc_activate(struct device *, int);
int imc_print(void *, const char *);
const struct cfattach imc_ca = {
- sizeof(struct device), imc_match, imc_attach
+ sizeof(struct device), imc_match, imc_attach, NULL, imc_activate
};
struct cfdriver imc_cd = {
@@ -699,6 +700,23 @@ imc_attach(struct device *parent, struct device *self, void *aux)
}
int
+imc_activate(struct device *self, int act)
+{
+ int rv = 0;
+
+ switch (act) {
+ case DVACT_POWERDOWN:
+#ifndef SMALL_KERNEL
+ wdog_shutdown(self);
+#endif
+ rv = config_activate_children(self, act);
+ break;
+ }
+
+ return (rv);
+}
+
+int
imc_print(void *aux, const char *name)
{
struct imc_attach_args *iaa = aux;
diff --git a/sys/arch/sparc64/dev/lom.c b/sys/arch/sparc64/dev/lom.c
index 883b90df077..e55a501b9a6 100644
--- a/sys/arch/sparc64/dev/lom.c
+++ b/sys/arch/sparc64/dev/lom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lom.c,v 1.24 2013/05/30 16:15:01 deraadt Exp $ */
+/* $OpenBSD: lom.c,v 1.25 2014/12/10 12:27:57 mikeb Exp $ */
/*
* Copyright (c) 2009 Mark Kettenis
*
@@ -368,6 +368,7 @@ lom_activate(struct device *self, int act)
switch (act) {
case DVACT_POWERDOWN:
+ wdog_shutdown(self);
lom_shutdown(self);
break;
}
diff --git a/sys/arch/sparc64/dev/pmc.c b/sys/arch/sparc64/dev/pmc.c
index 77bd9f0ed68..5f0c19496e9 100644
--- a/sys/arch/sparc64/dev/pmc.c
+++ b/sys/arch/sparc64/dev/pmc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmc.c,v 1.3 2012/10/17 22:32:01 deraadt Exp $ */
+/* $OpenBSD: pmc.c,v 1.4 2014/12/10 12:27:57 mikeb Exp $ */
/*
* Copyright (c) 2007 Mark Kettenis
@@ -50,10 +50,11 @@ struct pmc_softc {
int pmc_match(struct device *, void *, void *);
void pmc_attach(struct device *, struct device *, void *);
+int pmc_activate(struct device *, int);
int pmc_wdog_cb(void *, int);
struct cfattach pmc_ca = {
- sizeof(struct pmc_softc), pmc_match, pmc_attach
+ sizeof(struct pmc_softc), pmc_match, pmc_attach, NULL, pmc_activate
};
struct cfdriver pmc_cd = {
@@ -103,6 +104,18 @@ pmc_attach(struct device *parent, struct device *self, void *aux)
}
int
+pmc_activate(struct device *self, int act)
+{
+ switch (act) {
+ case DVACT_POWERDOWN:
+ wdog_shutdown(self);
+ break;
+ }
+
+ return (0);
+}
+
+int
pmc_wdog_cb(void *arg, int period)
{
struct pmc_softc *sc = arg;
diff --git a/sys/dev/ipmi.c b/sys/dev/ipmi.c
index 5556db905ad..b53d643ac90 100644
--- a/sys/dev/ipmi.c
+++ b/sys/dev/ipmi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipmi.c,v 1.73 2014/10/21 08:48:38 uebayasi Exp $ */
+/* $OpenBSD: ipmi.c,v 1.74 2014/12/10 12:27:57 mikeb Exp $ */
/*
* Copyright (c) 2005 Jordan Hargrave
@@ -158,6 +158,7 @@ int ipmi_watchdog(void *, int);
int ipmi_intr(void *);
int ipmi_match(struct device *, void *, void *);
void ipmi_attach(struct device *, struct device *, void *);
+int ipmi_activate(struct device *, int);
long ipow(long, int);
long ipmi_convert(u_int8_t, struct sdrtype1 *, long);
@@ -835,7 +836,8 @@ struct ipmi_bmc_response {
};
struct cfattach ipmi_ca = {
- sizeof(struct ipmi_softc), ipmi_match, ipmi_attach
+ sizeof(struct ipmi_softc), ipmi_match, ipmi_attach,
+ NULL, ipmi_activate
};
struct cfdriver ipmi_cd = {
@@ -1761,6 +1763,18 @@ ipmi_attach(struct device *parent, struct device *self, void *aux)
}
int
+ipmi_activate(struct device *self, int act)
+{
+ switch (act) {
+ case DVACT_POWERDOWN:
+ wdog_shutdown(self);
+ break;
+ }
+
+ return (0);
+}
+
+int
ipmi_watchdog(void *arg, int period)
{
struct ipmi_softc *sc = arg;
diff --git a/sys/dev/isa/fins.c b/sys/dev/isa/fins.c
index af5087fb17e..5fd0a256466 100644
--- a/sys/dev/isa/fins.c
+++ b/sys/dev/isa/fins.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fins.c,v 1.3 2012/10/17 22:32:01 deraadt Exp $ */
+/* $OpenBSD: fins.c,v 1.4 2014/12/10 12:27:57 mikeb Exp $ */
/*
* Copyright (c) 2005, 2006 Mark Kettenis
@@ -124,6 +124,7 @@ struct fins_softc {
int fins_match(struct device *, void *, void *);
void fins_attach(struct device *, struct device *, void *);
+int fins_activate(struct device *, int);
void fins_unlock(bus_space_tag_t, bus_space_handle_t);
void fins_lock(bus_space_tag_t, bus_space_handle_t);
@@ -150,7 +151,9 @@ int fins_wdog_cb(void *, int);
struct cfattach fins_ca = {
sizeof(struct fins_softc),
fins_match,
- fins_attach
+ fins_attach,
+ NULL,
+ fins_activate
};
struct cfdriver fins_cd = {
@@ -305,6 +308,18 @@ attach_done:
printf("\n");
}
+int
+fins_activate(struct device *self, int act)
+{
+ switch (act) {
+ case DVACT_POWERDOWN:
+ wdog_shutdown(self);
+ break;
+ }
+
+ return (0);
+}
+
u_int8_t
fins_read(bus_space_tag_t iot, bus_space_handle_t ioh, int reg)
{
diff --git a/sys/dev/isa/it.c b/sys/dev/isa/it.c
index 90a1801496c..b656e1ec57e 100644
--- a/sys/dev/isa/it.c
+++ b/sys/dev/isa/it.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: it.c,v 1.44 2013/04/10 01:35:55 guenther Exp $ */
+/* $OpenBSD: it.c,v 1.45 2014/12/10 12:27:57 mikeb Exp $ */
/*
* Copyright (c) 2007-2008 Oleg Safiullin <form@pdp-11.org.ru>
@@ -48,6 +48,7 @@
int it_match(struct device *, void *, void *);
void it_attach(struct device *, struct device *, void *);
+int it_activate(struct device *, int);
u_int8_t it_readreg(bus_space_tag_t, bus_space_handle_t, int);
void it_writereg(bus_space_tag_t, bus_space_handle_t, int, u_int8_t);
void it_enter(bus_space_tag_t, bus_space_handle_t, int);
@@ -289,6 +290,18 @@ it_attach(struct device *parent, struct device *self, void *aux)
sensordev_install(&sc->sc_sensordev);
}
+int
+it_activate(struct device *self, int act)
+{
+ switch (act) {
+ case DVACT_POWERDOWN:
+ wdog_shutdown(self);
+ break;
+ }
+
+ return (0);
+}
+
u_int8_t
it_readreg(bus_space_tag_t iot, bus_space_handle_t ioh, int r)
{
@@ -525,7 +538,9 @@ it_wdog_cb(void *arg, int period)
struct cfattach it_ca = {
sizeof(struct it_softc),
it_match,
- it_attach
+ it_attach,
+ NULL,
+ it_activate
};
struct cfdriver it_cd = {
diff --git a/sys/dev/isa/sch311x.c b/sys/dev/isa/sch311x.c
index 87cd1da851e..70eaf2966e0 100644
--- a/sys/dev/isa/sch311x.c
+++ b/sys/dev/isa/sch311x.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sch311x.c,v 1.13 2012/10/17 22:32:01 deraadt Exp $ */
+/* $OpenBSD: sch311x.c,v 1.14 2014/12/10 12:27:57 mikeb Exp $ */
/*
* Copyright (c) 2008 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2009 Michael Knudsen <mk@openbsd.org>
@@ -160,6 +160,7 @@ struct schsio_softc {
int schsio_probe(struct device *, void *, void *);
void schsio_attach(struct device *, struct device *, void *);
+int schsio_activate(struct device *, int);
static __inline void schsio_config_enable(bus_space_tag_t iot,
bus_space_handle_t ioh);
@@ -184,7 +185,9 @@ int schsio_wdt_cb(void *arg, int period);
struct cfattach schsio_ca = {
sizeof(struct schsio_softc),
schsio_probe,
- schsio_attach
+ schsio_attach,
+ NULL,
+ schsio_activate
};
struct cfdriver schsio_cd = {
@@ -318,6 +321,18 @@ schsio_attach(struct device *parent, struct device *self, void *aux)
schsio_config_disable(sc->sc_iot, sc->sc_ioh);
}
+int
+schsio_activate(struct device *self, int act)
+{
+ switch (act) {
+ case DVACT_POWERDOWN:
+ wdog_shutdown(self);
+ break;
+ }
+
+ return (0);
+}
+
void
schsio_hwm_init(struct schsio_softc *sc)
{
diff --git a/sys/dev/isa/viasio.c b/sys/dev/isa/viasio.c
index 3b82c46ded5..32d2b9f29d3 100644
--- a/sys/dev/isa/viasio.c
+++ b/sys/dev/isa/viasio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: viasio.c,v 1.13 2012/10/17 22:32:01 deraadt Exp $ */
+/* $OpenBSD: viasio.c,v 1.14 2014/12/10 12:27:57 mikeb Exp $ */
/*
* Copyright (c) 2005 Alexander Yurchenko <grange@openbsd.org>
*
@@ -62,6 +62,7 @@ struct viasio_softc {
int viasio_probe(struct device *, void *, void *);
void viasio_attach(struct device *, struct device *, void *);
+int viasio_activate(struct device *, int);
void viasio_hm_init(struct viasio_softc *);
void viasio_hm_refresh(void *);
@@ -72,7 +73,9 @@ int viasio_wdg_cb(void *, int);
struct cfattach viasio_ca = {
sizeof(struct viasio_softc),
viasio_probe,
- viasio_attach
+ viasio_attach,
+ NULL,
+ viasio_activate
};
struct cfdriver viasio_cd = {
@@ -196,6 +199,18 @@ viasio_attach(struct device *parent, struct device *self, void *aux)
viasio_conf_disable(sc->sc_iot, sc->sc_ioh);
}
+int
+viasio_activate(struct device *self, int act)
+{
+ switch (act) {
+ case DVACT_POWERDOWN:
+ wdog_shutdown(self);
+ break;
+ }
+
+ return (0);
+}
+
void
viasio_hm_init(struct viasio_softc *sc)
{
diff --git a/sys/dev/pci/berkwdt.c b/sys/dev/pci/berkwdt.c
index 47eaaa1c593..250f3973575 100644
--- a/sys/dev/pci/berkwdt.c
+++ b/sys/dev/pci/berkwdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: berkwdt.c,v 1.7 2012/10/17 22:32:01 deraadt Exp $ */
+/* $OpenBSD: berkwdt.c,v 1.8 2014/12/10 12:27:57 mikeb Exp $ */
/*
* Copyright (c) 2009 Wim Van Sebroeck <wim@iguana.be>
@@ -46,6 +46,7 @@ struct berkwdt_softc {
int berkwdt_match(struct device *, void *, void *);
void berkwdt_attach(struct device *, struct device *, void *);
+int berkwdt_activate(struct device *, int);
void berkwdt_start(struct berkwdt_softc *sc);
void berkwdt_stop(struct berkwdt_softc *sc);
@@ -55,7 +56,8 @@ int berkwdt_send_command(struct berkwdt_softc *sc, u_int8_t cmd, int *val);
int berkwdt_set_timeout(void *, int);
struct cfattach berkwdt_ca = {
- sizeof(struct berkwdt_softc), berkwdt_match, berkwdt_attach
+ sizeof(struct berkwdt_softc), berkwdt_match, berkwdt_attach,
+ NULL, berkwdt_activate
};
struct cfdriver berkwdt_cd = {
@@ -214,6 +216,18 @@ berkwdt_attach(struct device *parent, struct device *self, void *aux)
}
int
+berkwdt_activate(struct device *self, int act)
+{
+ switch (act) {
+ case DVACT_POWERDOWN:
+ wdog_shutdown(self);
+ break;
+ }
+
+ return (0);
+}
+
+int
berkwdt_set_timeout(void *self, int timeout)
{
struct berkwdt_softc *sc = self;
diff --git a/sys/dev/pci/glxpcib.c b/sys/dev/pci/glxpcib.c
index b68efd79ab0..1953a5a424f 100644
--- a/sys/dev/pci/glxpcib.c
+++ b/sys/dev/pci/glxpcib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: glxpcib.c,v 1.13 2014/10/08 16:07:45 deraadt Exp $ */
+/* $OpenBSD: glxpcib.c,v 1.14 2014/12/10 12:27:57 mikeb Exp $ */
/*
* Copyright (c) 2007 Marc Balmer <mbalmer@openbsd.org>
@@ -454,6 +454,13 @@ glxpcib_activate(struct device *self, int act)
#endif
rv = config_activate_children(self, act);
break;
+ case DVACT_POWERDOWN:
+#ifndef SMALL_KERNEL
+ if (sc->sc_wdog)
+ wdog_shutdown(self);
+#endif
+ rv = config_activate_children(self, act);
+ break;
default:
rv = config_activate_children(self, act);
break;
diff --git a/sys/dev/pci/ichwdt.c b/sys/dev/pci/ichwdt.c
index 2d690932bdc..ef03dc979ba 100644
--- a/sys/dev/pci/ichwdt.c
+++ b/sys/dev/pci/ichwdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ichwdt.c,v 1.4 2012/10/17 22:32:01 deraadt Exp $ */
+/* $OpenBSD: ichwdt.c,v 1.5 2014/12/10 12:27:57 mikeb Exp $ */
/*
* Copyright (c) 2004, 2005 Alexander Yurchenko <grange@openbsd.org>
@@ -53,13 +53,16 @@ struct ichwdt_softc {
int ichwdt_match(struct device *, void *, void *);
void ichwdt_attach(struct device *, struct device *, void *);
+int ichwdt_activate(struct device *, int);
int ichwdt_cb(void *, int);
struct cfattach ichwdt_ca = {
sizeof(struct ichwdt_softc),
ichwdt_match,
- ichwdt_attach
+ ichwdt_attach,
+ NULL,
+ ichwdt_activate
};
struct cfdriver ichwdt_cd = {
@@ -140,6 +143,18 @@ ichwdt_attach(struct device *parent, struct device *self, void *aux)
}
int
+ichwdt_activate(struct device *self, int act)
+{
+ switch (act) {
+ case DVACT_POWERDOWN:
+ wdog_shutdown(self);
+ break;
+ }
+
+ return (0);
+}
+
+int
ichwdt_cb(void *arg, int period)
{
struct ichwdt_softc *sc = arg;
diff --git a/sys/dev/pci/pwdog.c b/sys/dev/pci/pwdog.c
index c95d9aeb116..b3f48e06e30 100644
--- a/sys/dev/pci/pwdog.c
+++ b/sys/dev/pci/pwdog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pwdog.c,v 1.8 2012/10/17 22:32:01 deraadt Exp $ */
+/* $OpenBSD: pwdog.c,v 1.9 2014/12/10 12:27:57 mikeb Exp $ */
/*
* Copyright (c) 2006 Marc Balmer <mbalmer@openbsd.org>
@@ -40,10 +40,12 @@ struct pwdog_softc {
int pwdog_probe(struct device *, void *, void *);
void pwdog_attach(struct device *, struct device *, void *);
+int pwdog_activate(struct device *, int);
int pwdog_set_timeout(void *, int);
struct cfattach pwdog_ca = {
- sizeof(struct pwdog_softc), pwdog_probe, pwdog_attach
+ sizeof(struct pwdog_softc), pwdog_probe, pwdog_attach,
+ NULL, pwdog_activate
};
struct cfdriver pwdog_cd = {
@@ -83,6 +85,18 @@ pwdog_attach(struct device *parent, struct device *self, void *aux)
}
int
+pwdog_activate(struct device *self, int act)
+{
+ switch (act) {
+ case DVACT_POWERDOWN:
+ wdog_shutdown(self);
+ break;
+ }
+
+ return (0);
+}
+
+int
pwdog_set_timeout(void *self, int seconds)
{
struct pwdog_softc *pwdog = (struct pwdog_softc *)self;
diff --git a/sys/dev/pci/tcpcib.c b/sys/dev/pci/tcpcib.c
index 97c8f445cf8..c9f54d8b3f4 100644
--- a/sys/dev/pci/tcpcib.c
+++ b/sys/dev/pci/tcpcib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcpcib.c,v 1.7 2013/12/06 21:03:04 deraadt Exp $ */
+/* $OpenBSD: tcpcib.c,v 1.8 2014/12/10 12:27:57 mikeb Exp $ */
/*
* Copyright (c) 2012 Matt Dainty <matt@bodgit-n-scarper.com>
@@ -295,6 +295,11 @@ tcpcib_activate(struct device *self, int act)
E600_HPET_GC, E600_HPET_GC_ENABLE);
rv = config_activate_children(self, act);
break;
+ case DVACT_POWERDOWN:
+ if (sc->sc_active & E600_WDT_ACTIVE)
+ wdog_shutdown(self);
+ rv = config_activate_children(self, act);
+ break;
default:
rv = config_activate_children(self, act);
break;
diff --git a/sys/dev/pci/wdt.c b/sys/dev/pci/wdt.c
index 2b48fe304f2..874864bc18b 100644
--- a/sys/dev/pci/wdt.c
+++ b/sys/dev/pci/wdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wdt.c,v 1.21 2012/10/17 22:32:01 deraadt Exp $ */
+/* $OpenBSD: wdt.c,v 1.22 2014/12/10 12:27:57 mikeb Exp $ */
/*-
* Copyright (c) 1998,1999 Alex Nash
@@ -53,6 +53,7 @@ struct wdt_softc {
int wdt_probe(struct device *, void *, void *);
void wdt_attach(struct device *, struct device *, void *);
+int wdt_activate(struct device *, int);
int wdt_is501(struct wdt_softc *);
void wdt_8254_count(struct wdt_softc *, int, u_int16_t);
@@ -64,7 +65,8 @@ void wdt_timer_disable(struct wdt_softc *);
void wdt_buzzer_enable(struct wdt_softc *);
struct cfattach wdt_ca = {
- sizeof(struct wdt_softc), wdt_probe, wdt_attach
+ sizeof(struct wdt_softc), wdt_probe, wdt_attach,
+ NULL, wdt_activate
};
struct cfdriver wdt_cd = {
@@ -159,6 +161,18 @@ wdt_attach(struct device *parent, struct device *self, void *aux)
wdog_register(wdt_set_timeout, wdt);
}
+int
+wdt_activate(struct device *self, int act)
+{
+ switch (act) {
+ case DVACT_POWERDOWN:
+ wdog_shutdown(self);
+ break;
+ }
+
+ return (0);
+}
+
/*
* wdt_is501
*
diff --git a/sys/kern/kern_watchdog.c b/sys/kern/kern_watchdog.c
index 0bad9de379f..5c27b17bb4e 100644
--- a/sys/kern/kern_watchdog.c
+++ b/sys/kern/kern_watchdog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_watchdog.c,v 1.10 2014/09/14 14:17:25 jsg Exp $ */
+/* $OpenBSD: kern_watchdog.c,v 1.11 2014/12/10 12:27:57 mikeb Exp $ */
/*
* Copyright (c) 2003 Markus Friedl. All rights reserved.
@@ -35,7 +35,6 @@ int (*wdog_ctl_cb)(void *, int) = NULL;
void *wdog_ctl_cb_arg = NULL;
int wdog_period = 0;
int wdog_auto = 1;
-void *wdog_cookie;
struct timeout wdog_timeout;
void
@@ -47,7 +46,6 @@ wdog_register(int (*cb)(void *, int), void *cb_arg)
wdog_ctl_cb = cb;
wdog_ctl_cb_arg = cb_arg;
timeout_set(&wdog_timeout, wdog_tickle, NULL);
- wdog_cookie = shutdownhook_establish((void (*)(void *))wdog_shutdown, NULL);
}
void
@@ -60,9 +58,9 @@ wdog_tickle(void *arg)
}
void
-wdog_shutdown(int (*cb)(void *, int), void *cb_arg)
+wdog_shutdown(void *arg)
{
- if (wdog_ctl_cb == NULL)
+ if (wdog_ctl_cb == NULL || wdog_ctl_cb_arg != arg)
return;
timeout_del(&wdog_timeout);
(void) (*wdog_ctl_cb)(wdog_ctl_cb_arg, 0);
@@ -95,17 +93,10 @@ sysctl_wdog(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
error = sysctl_int(oldp, oldlenp, newp, newlen, &wdog_auto);
if (error)
return (error);
- if (wdog_auto && wdog_cookie == NULL)
- wdog_cookie = shutdownhook_establish((void (*)(void *))wdog_shutdown,
- NULL);
- else if (!wdog_auto && wdog_cookie) {
- shutdownhook_disestablish(wdog_cookie);
- wdog_cookie = NULL;
- }
break;
default:
return (EINVAL);
- }
+ }
if (wdog_auto && wdog_period > 0) {
(void) (*wdog_ctl_cb)(wdog_ctl_cb_arg, wdog_period);
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
index 9587c7a586f..0566e5be41d 100644
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: systm.h,v 1.104 2014/11/18 18:34:50 miod Exp $ */
+/* $OpenBSD: systm.h,v 1.105 2014/12/10 12:27:57 mikeb Exp $ */
/* $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $ */
/*-
@@ -260,7 +260,7 @@ int msleep(const volatile void *, struct mutex *, int, const char*, int);
void yield(void);
void wdog_register(int (*)(void *, int), void *);
-void wdog_shutdown(int (*)(void *, int), void *);
+void wdog_shutdown(void *);
/*
* Startup/shutdown hooks. Startup hooks are functions running after