aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/ichwd
diff options
context:
space:
mode:
authorNick Hibma <n_hibma@FreeBSD.org>2006-12-15 21:44:49 +0000
committerNick Hibma <n_hibma@FreeBSD.org>2006-12-15 21:44:49 +0000
commit9079fff5504650793319895e16f3f9cd431c5ec5 (patch)
tree787bbfce7ce18dfa578e01e209a342d73f933983 /sys/dev/ichwd
parent2cd19db26a49002206f71dfa91a0278aa7b43977 (diff)
Notes
Diffstat (limited to 'sys/dev/ichwd')
-rw-r--r--sys/dev/ichwd/ichwd.c42
1 files changed, 12 insertions, 30 deletions
diff --git a/sys/dev/ichwd/ichwd.c b/sys/dev/ichwd/ichwd.c
index 8ddeb8ce3c5bb..f878d39f9339e 100644
--- a/sys/dev/ichwd/ichwd.c
+++ b/sys/dev/ichwd/ichwd.c
@@ -178,38 +178,22 @@ ichwd_event(void *arg, unsigned int cmd, int *error)
struct ichwd_softc *sc = arg;
unsigned int timeout;
+ /* convert from power-of-two-ns to WDT ticks */
+ cmd &= WD_INTERVAL;
+ timeout = ((uint64_t)1 << cmd) / ICHWD_TICK;
+ if (cmd > 0 && cmd <= 63
+ && timeout >= ICHWD_MIN_TIMEOUT && timeout <= ICHWD_MAX_TIMEOUT) {
+ if (timeout != sc->timeout)
+ ichwd_tmr_set(sc, timeout);
- /* disable / enable */
- if (!(cmd & WD_ACTIVE)) {
+ ichwd_tmr_reload(sc);
+ *error = 0;
+ } else {
if (sc->active)
ichwd_tmr_disable(sc);
- *error = 0;
- return;
- }
- if (!sc->active)
- ichwd_tmr_enable(sc);
-
- cmd &= WD_INTERVAL;
- /* convert from power-of-to-ns to WDT ticks */
- if (cmd >= 64) {
- *error = EINVAL;
- return;
- }
- timeout = ((uint64_t)1 << cmd) / ICHWD_TICK;
- if (timeout < ICHWD_MIN_TIMEOUT || timeout > ICHWD_MAX_TIMEOUT) {
- *error = EINVAL;
- return;
+ if (cmd > 0)
+ *error = EINVAL;
}
-
- /* set new initial value */
- if (timeout != sc->timeout)
- ichwd_tmr_set(sc, timeout);
-
- /* reload */
- ichwd_tmr_reload(sc);
-
- *error = 0;
- return;
}
static unsigned int pmbase = 0;
@@ -332,8 +316,6 @@ ichwd_detach(device_t dev)
{
struct ichwd_softc *sc;
- device_printf(dev, "detaching\n");
-
sc = device_get_softc(dev);
/* halt the watchdog timer */