summaryrefslogtreecommitdiff
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorWim Van Sebroeck <wim@iguana.be>2011-07-22 18:56:38 +0000
committerWim Van Sebroeck <wim@iguana.be>2011-07-28 08:01:05 +0000
commit2fa03560ab3a6dd83cad9bfd5692179fc2ceabb3 (patch)
treeb208649368917b6c8d16c5cc737b2b83e906d074 /drivers/watchdog
parent43316044d4f64da008d6aca7d4b60771b9a24eb8 (diff)
watchdog: WatchDog Timer Driver Core - Add basic ioctl functionality
This part add's the basic ioctl functionality to the WatchDog Timer Driver Core framework. The supported ioctl call's are: WDIOC_GETSUPPORT WDIOC_GETSTATUS WDIOC_GETBOOTSTATUS Signed-off-by: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Wim Van Sebroeck <wim@iguana.be> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Wolfram Sang <w.sang@pengutronix.de>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/watchdog_dev.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 366f49ce69b8..00a611293065 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -95,6 +95,37 @@ static ssize_t watchdog_write(struct file *file, const char __user *data,
}
/*
+ * watchdog_ioctl: handle the different ioctl's for the watchdog device.
+ * @file: file handle to the device
+ * @cmd: watchdog command
+ * @arg: argument pointer
+ *
+ * The watchdog API defines a common set of functions for all watchdogs
+ * according to their available features.
+ */
+
+static long watchdog_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
+{
+ void __user *argp = (void __user *)arg;
+ int __user *p = argp;
+ unsigned int val;
+
+ switch (cmd) {
+ case WDIOC_GETSUPPORT:
+ return copy_to_user(argp, wdd->info,
+ sizeof(struct watchdog_info)) ? -EFAULT : 0;
+ case WDIOC_GETSTATUS:
+ val = wdd->ops->status ? wdd->ops->status(wdd) : 0;
+ return put_user(val, p);
+ case WDIOC_GETBOOTSTATUS:
+ return put_user(wdd->bootstatus, p);
+ default:
+ return -ENOTTY;
+ }
+}
+
+/*
* watchdog_open: open the /dev/watchdog device.
* @inode: inode of device
* @file: file handle to device
@@ -163,6 +194,7 @@ static int watchdog_release(struct inode *inode, struct file *file)
static const struct file_operations watchdog_fops = {
.owner = THIS_MODULE,
.write = watchdog_write,
+ .unlocked_ioctl = watchdog_ioctl,
.open = watchdog_open,
.release = watchdog_release,
};