diff options
author | Wim Van Sebroeck <wim@iguana.be> | 2011-07-22 14:56:38 -0400 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2011-07-28 04:01:05 -0400 |
commit | 2fa03560ab3a6dd83cad9bfd5692179fc2ceabb3 (patch) | |
tree | b208649368917b6c8d16c5cc737b2b83e906d074 /drivers/watchdog | |
parent | 43316044d4f64da008d6aca7d4b60771b9a24eb8 (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.c | 32 |
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, | |||
95 | } | 95 | } |
96 | 96 | ||
97 | /* | 97 | /* |
98 | * watchdog_ioctl: handle the different ioctl's for the watchdog device. | ||
99 | * @file: file handle to the device | ||
100 | * @cmd: watchdog command | ||
101 | * @arg: argument pointer | ||
102 | * | ||
103 | * The watchdog API defines a common set of functions for all watchdogs | ||
104 | * according to their available features. | ||
105 | */ | ||
106 | |||
107 | static long watchdog_ioctl(struct file *file, unsigned int cmd, | ||
108 | unsigned long arg) | ||
109 | { | ||
110 | void __user *argp = (void __user *)arg; | ||
111 | int __user *p = argp; | ||
112 | unsigned int val; | ||
113 | |||
114 | switch (cmd) { | ||
115 | case WDIOC_GETSUPPORT: | ||
116 | return copy_to_user(argp, wdd->info, | ||
117 | sizeof(struct watchdog_info)) ? -EFAULT : 0; | ||
118 | case WDIOC_GETSTATUS: | ||
119 | val = wdd->ops->status ? wdd->ops->status(wdd) : 0; | ||
120 | return put_user(val, p); | ||
121 | case WDIOC_GETBOOTSTATUS: | ||
122 | return put_user(wdd->bootstatus, p); | ||
123 | default: | ||
124 | return -ENOTTY; | ||
125 | } | ||
126 | } | ||
127 | |||
128 | /* | ||
98 | * watchdog_open: open the /dev/watchdog device. | 129 | * watchdog_open: open the /dev/watchdog device. |
99 | * @inode: inode of device | 130 | * @inode: inode of device |
100 | * @file: file handle to device | 131 | * @file: file handle to device |
@@ -163,6 +194,7 @@ static int watchdog_release(struct inode *inode, struct file *file) | |||
163 | static const struct file_operations watchdog_fops = { | 194 | static const struct file_operations watchdog_fops = { |
164 | .owner = THIS_MODULE, | 195 | .owner = THIS_MODULE, |
165 | .write = watchdog_write, | 196 | .write = watchdog_write, |
197 | .unlocked_ioctl = watchdog_ioctl, | ||
166 | .open = watchdog_open, | 198 | .open = watchdog_open, |
167 | .release = watchdog_release, | 199 | .release = watchdog_release, |
168 | }; | 200 | }; |