diff options
author | Robin Gong <b38343@freescale.com> | 2015-11-02 16:39:02 +0800 |
---|---|---|
committer | Nitin Garg <nitin.garg@nxp.com> | 2016-01-14 11:02:12 -0600 |
commit | 997ab6d6e2ca214a7d6609ec2a1c0f57f3ff0080 (patch) | |
tree | f61da554784c7dd4d615ff73b701a940bbebf0af /drivers/watchdog/watchdog_dev.c | |
parent | ed2775fd67ad03b7069b37ddcaa36bc57b9e48cb (diff) |
MLK-11808-2: watchdog: add WDIOC_SETPRETIMEOUT and WDIOC_GETPRETIMEOUT
Since the watchdog common framework centrialize the IOCTL interfaces of device
driver now, the SETPRETIMEOUT and GETPRETIMEOUT need to be added in common code
Signed-off-by: Robin Gong <b38343@freescale.com>
Diffstat (limited to 'drivers/watchdog/watchdog_dev.c')
-rw-r--r-- | drivers/watchdog/watchdog_dev.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index 6aaefbad303e..02632fe8fa84 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -218,6 +218,37 @@ out_timeout: } /* + * watchdog_set_pretimeout: set the watchdog timer pretimeout + * @wddev: the watchdog device to set the timeout for + * @timeout: pretimeout to set in seconds + */ + +static int watchdog_set_pretimeout(struct watchdog_device *wddev, + unsigned int timeout) +{ + int err; + + if ((wddev->ops->set_pretimeout == NULL) || + !(wddev->info->options & WDIOF_PRETIMEOUT)) + return -EOPNOTSUPP; + if (watchdog_pretimeout_invalid(wddev, timeout)) + return -EINVAL; + + mutex_lock(&wddev->lock); + + if (test_bit(WDOG_UNREGISTERED, &wddev->status)) { + err = -ENODEV; + goto out_timeout; + } + + err = wddev->ops->set_pretimeout(wddev, timeout); + +out_timeout: + mutex_unlock(&wddev->lock); + return err; +} + +/* * watchdog_get_timeleft: wrapper to get the time left before a reboot * @wddev: the watchdog device to get the remaining time from * @timeleft: the time that's left @@ -393,6 +424,13 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd, if (err) return err; return put_user(val, p); + case WDIOC_SETPRETIMEOUT: + if (get_user(val, p)) + return -EFAULT; + err = watchdog_set_pretimeout(wdd, val); + return err; + case WDIOC_GETPRETIMEOUT: + return put_user(wdd->pretimeout, p); default: return -ENOTTY; } |