diff options
author | n_hibma <n_hibma@FreeBSD.org> | 2007-03-27 21:03:37 +0000 |
---|---|---|
committer | n_hibma <n_hibma@FreeBSD.org> | 2007-03-27 21:03:37 +0000 |
commit | 2e4f7510d94a26f1cd9ae67ea9c88535cea9c193 (patch) | |
tree | c7550e0408ca0d79f56a9e6d3c0a0ca79a6f86e2 | |
parent | 2f20235351089bb6e52be91ffa6c7bf6ded46a69 (diff) | |
download | FreeBSD-src-2e4f7510d94a26f1cd9ae67ea9c88535cea9c193.zip FreeBSD-src-2e4f7510d94a26f1cd9ae67ea9c88535cea9c193.tar.gz |
Revisit the watchdogs: Resetting the error to EINVAL after failing to set the
watchdog might hide the succesful arming of an earlier one. Accept that on
failing to arm any watchdog (because of non-supported timeouts) EOPNOTSUPP is
returned instead of the more appropriate EINVAL.
MFC after: 3 days
-rw-r--r-- | sys/arm/at91/at91_st.c | 4 | ||||
-rw-r--r-- | sys/arm/xscale/i80321/i80321_wdog.c | 7 | ||||
-rw-r--r-- | sys/arm/xscale/ixp425/ixp425_wdog.c | 2 | ||||
-rw-r--r-- | sys/dev/ichwd/ichwd.c | 2 | ||||
-rw-r--r-- | sys/dev/ipmi/ipmi.c | 2 | ||||
-rw-r--r-- | sys/dev/mk48txx/mk48txx.c | 8 | ||||
-rw-r--r-- | sys/dev/watchdog/watchdog.c | 2 | ||||
-rw-r--r-- | sys/i386/i386/elan-mmcr.c | 2 | ||||
-rw-r--r-- | sys/i386/i386/geode.c | 7 |
9 files changed, 15 insertions, 21 deletions
diff --git a/sys/arm/at91/at91_st.c b/sys/arm/at91/at91_st.c index 6ec9730..9905113 100644 --- a/sys/arm/at91/at91_st.c +++ b/sys/arm/at91/at91_st.c @@ -171,13 +171,11 @@ at91st_watchdog(void *argp, u_int cmd, int *error) int t; t = cmd & WD_INTERVAL; - if (cmd > 0 && t >= 22 && t <= 37) { + if (t >= 22 && t <= 37) { wdog = (1 << (t - 22)) | ST_WDMR_RSTEN; *error = 0; } else { wdog = 0; - if (cmd > 0) - *error = EINVAL; } WR4(ST_WDMR, wdog); WR4(ST_CR, ST_CR_WDRST); diff --git a/sys/arm/xscale/i80321/i80321_wdog.c b/sys/arm/xscale/i80321/i80321_wdog.c index c6c749c..eff5f9d 100644 --- a/sys/arm/xscale/i80321/i80321_wdog.c +++ b/sys/arm/xscale/i80321/i80321_wdog.c @@ -111,18 +111,15 @@ iopwdog_watchdog_fn(void *private, u_int cmd, int *error) cmd &= WD_INTERVAL; if (cmd > 0 && cmd <= 63 - && (uint64_t)1 << (cmd & WD_INTERVAL) <= - (uint64_t)sc->wdog_period * 1000000000) { + && (uint64_t)1<<cmd <= (uint64_t)sc->wdog_period * 1000000000) { /* Valid value -> Enable watchdog */ iopwdog_tickle(sc); sc->armed = 1; *error = 0; } else { - /* XXX Can't disable this watchdog? */ + /* Can't disable this watchdog! */ if (sc->armed) *error = EOPNOTSUPP; - else if (cmd > 0) - *error = EINVAL; } } diff --git a/sys/arm/xscale/ixp425/ixp425_wdog.c b/sys/arm/xscale/ixp425/ixp425_wdog.c index a94ef0a..9db9cce 100644 --- a/sys/arm/xscale/ixp425/ixp425_wdog.c +++ b/sys/arm/xscale/ixp425/ixp425_wdog.c @@ -70,7 +70,7 @@ ixp425_watchdog(void *arg, u_int cmd, int *error) u_int u = cmd & WD_INTERVAL; WR4(sc, IXP425_OST_WDOG_KEY, OST_WDOG_KEY_MAJICK); - if (cmd && 4 <= u && u <= 35) { + if (4 <= u && u <= 35) { WR4(sc, IXP425_OST_WDOG_ENAB, 0); /* approximate 66.66MHz cycles */ WR4(sc, IXP425_OST_WDOG, 2<<(u - 4)); diff --git a/sys/dev/ichwd/ichwd.c b/sys/dev/ichwd/ichwd.c index a109f80..86d9ad3 100644 --- a/sys/dev/ichwd/ichwd.c +++ b/sys/dev/ichwd/ichwd.c @@ -194,8 +194,6 @@ ichwd_event(void *arg, unsigned int cmd, int *error) } else { if (sc->active) ichwd_tmr_disable(sc); - if (cmd > 0) - *error = EINVAL; } } diff --git a/sys/dev/ipmi/ipmi.c b/sys/dev/ipmi/ipmi.c index 12cf3f5..d42aedc 100644 --- a/sys/dev/ipmi/ipmi.c +++ b/sys/dev/ipmi/ipmi.c @@ -656,8 +656,6 @@ ipmi_wd_event(void *arg, unsigned int cmd, int *error) *error = 0; } else { ipmi_set_watchdog(sc, 0); - if (cmd > 0) - *error = 0; } } diff --git a/sys/dev/mk48txx/mk48txx.c b/sys/dev/mk48txx/mk48txx.c index fbc03c4..71ab8f5 100644 --- a/sys/dev/mk48txx/mk48txx.c +++ b/sys/dev/mk48txx/mk48txx.c @@ -295,9 +295,9 @@ mk48txx_watchdog(void *arg, u_int cmd, int *error) dev = arg; sc = device_get_softc(dev); - wdog = 0; t = cmd & WD_INTERVAL; - if (cmd > 0 && t >= 26 && t <= 37) { + if (t >= 26 && t <= 37) { + wdog = 0; if (t <= WD_TO_2SEC) { wdog |= MK48TXX_WDOG_RB_1_16; t -= 26; @@ -317,8 +317,8 @@ mk48txx_watchdog(void *arg, u_int cmd, int *error) if (sc->sc_flag & MK48TXX_WDOG_ENABLE_WDS) wdog |= MK48TXX_WDOG_WDS; *error = 0; - } else if (cmd > 0) { - *error = EINVAL; + } else { + wdog = 0; } mtx_lock(&sc->sc_mtx); (*sc->sc_nvwr)(dev, sc->sc_clkoffset + MK48TXX_WDOG, wdog); diff --git a/sys/dev/watchdog/watchdog.c b/sys/dev/watchdog/watchdog.c index a1d8d88..06498c9 100644 --- a/sys/dev/watchdog/watchdog.c +++ b/sys/dev/watchdog/watchdog.c @@ -55,6 +55,8 @@ wd_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t data, return (EINVAL); if ((u & (WD_ACTIVE | WD_PASSIVE)) == (WD_ACTIVE | WD_PASSIVE)) return (EINVAL); + if ((u & (WD_ACTIVE | WD_PASSIVE)) == 0 && (u & WD_INTERVAL) > 0) + return (EINVAL); if (u & WD_PASSIVE) return (ENOSYS); /* XXX Not implemented yet */ if ((u & WD_INTERVAL) == WD_TO_NEVER) { diff --git a/sys/i386/i386/elan-mmcr.c b/sys/i386/i386/elan-mmcr.c index be3e2a4..6556167 100644 --- a/sys/i386/i386/elan-mmcr.c +++ b/sys/i386/i386/elan-mmcr.c @@ -412,8 +412,6 @@ elan_watchdog(void *foo __unused, u_int spec, int *error) elan_mmcr->WDTMRCTL = w; /* XXX What does this statement do? */ elan_mmcr->GPECHO = w; cur = 0; - if (u > 0) - *error = 0; } } diff --git a/sys/i386/i386/geode.c b/sys/i386/i386/geode.c index 14d73ea..650dcba 100644 --- a/sys/i386/i386/geode.c +++ b/sys/i386/i386/geode.c @@ -136,7 +136,7 @@ geode_watchdog(void *foo __unused, u_int cmd, int *error) u_int u, p, r; u = cmd & WD_INTERVAL; - if (cmd && u >= 14 && u <= 43) { + if (u >= 14 && u <= 43) { u -= 14; if (u > 16) { p = u - 16; @@ -165,7 +165,10 @@ geode_watchdog(void *foo __unused, u_int cmd, int *error) static void advantech_watchdog(void *foo __unused, u_int cmd, int *error) { - if (cmd && (cmd & WD_INTERVAL) <= WD_TO_1SEC) { + u_int u; + + u = cmd & WD_INTERVAL; + if (u > 0 && u <= WD_TO_1SEC) { outb(0x0443, 1); *error = 0; } else { |