diff options
| -rw-r--r-- | Documentation/watchdog/watchdog-kernel-api.txt | 6 | ||||
| -rw-r--r-- | drivers/watchdog/watchdog_dev.c | 32 | ||||
| -rw-r--r-- | include/linux/watchdog.h | 4 |
3 files changed, 42 insertions, 0 deletions
diff --git a/Documentation/watchdog/watchdog-kernel-api.txt b/Documentation/watchdog/watchdog-kernel-api.txt index 3db67e74b80e..2bdc6dc6e04c 100644 --- a/Documentation/watchdog/watchdog-kernel-api.txt +++ b/Documentation/watchdog/watchdog-kernel-api.txt | |||
| @@ -41,6 +41,7 @@ The watchdog device structure looks like this: | |||
| 41 | struct watchdog_device { | 41 | struct watchdog_device { |
| 42 | const struct watchdog_info *info; | 42 | const struct watchdog_info *info; |
| 43 | const struct watchdog_ops *ops; | 43 | const struct watchdog_ops *ops; |
| 44 | unsigned int bootstatus; | ||
| 44 | void *driver_data; | 45 | void *driver_data; |
| 45 | unsigned long status; | 46 | unsigned long status; |
| 46 | }; | 47 | }; |
| @@ -49,6 +50,8 @@ It contains following fields: | |||
| 49 | * info: a pointer to a watchdog_info structure. This structure gives some | 50 | * info: a pointer to a watchdog_info structure. This structure gives some |
| 50 | additional information about the watchdog timer itself. (Like it's unique name) | 51 | additional information about the watchdog timer itself. (Like it's unique name) |
| 51 | * ops: a pointer to the list of watchdog operations that the watchdog supports. | 52 | * ops: a pointer to the list of watchdog operations that the watchdog supports. |
| 53 | * bootstatus: status of the device after booting (reported with watchdog | ||
| 54 | WDIOF_* status bits). | ||
| 52 | * driver_data: a pointer to the drivers private data of a watchdog device. | 55 | * driver_data: a pointer to the drivers private data of a watchdog device. |
| 53 | This data should only be accessed via the watchdog_set_drvadata and | 56 | This data should only be accessed via the watchdog_set_drvadata and |
| 54 | watchdog_get_drvdata routines. | 57 | watchdog_get_drvdata routines. |
| @@ -65,6 +68,7 @@ struct watchdog_ops { | |||
| 65 | int (*stop)(struct watchdog_device *); | 68 | int (*stop)(struct watchdog_device *); |
| 66 | /* optional operations */ | 69 | /* optional operations */ |
| 67 | int (*ping)(struct watchdog_device *); | 70 | int (*ping)(struct watchdog_device *); |
| 71 | unsigned int (*status)(struct watchdog_device *); | ||
| 68 | }; | 72 | }; |
| 69 | 73 | ||
| 70 | It is important that you first define the module owner of the watchdog timer | 74 | It is important that you first define the module owner of the watchdog timer |
| @@ -97,6 +101,8 @@ they are supported. These optional routines/operations are: | |||
| 97 | the watchdog timer driver core does: to send a keepalive ping to the watchdog | 101 | the watchdog timer driver core does: to send a keepalive ping to the watchdog |
| 98 | timer hardware it will either use the ping operation (when available) or the | 102 | timer hardware it will either use the ping operation (when available) or the |
| 99 | start operation (when the ping operation is not available). | 103 | start operation (when the ping operation is not available). |
| 104 | * status: this routine checks the status of the watchdog timer device. The | ||
| 105 | status of the device is reported with watchdog WDIOF_* status flags/bits. | ||
| 100 | 106 | ||
| 101 | The status bits should (preferably) be set with the set_bit and clear_bit alike | 107 | The status bits should (preferably) be set with the set_bit and clear_bit alike |
| 102 | bit-operations. The status bits that are defined are: | 108 | bit-operations. The status bits that are defined are: |
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 | }; |
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h index 5ab31bfd2906..29ff80807dd4 100644 --- a/include/linux/watchdog.h +++ b/include/linux/watchdog.h | |||
| @@ -68,6 +68,7 @@ struct watchdog_device; | |||
| 68 | * @start: The routine for starting the watchdog device. | 68 | * @start: The routine for starting the watchdog device. |
| 69 | * @stop: The routine for stopping the watchdog device. | 69 | * @stop: The routine for stopping the watchdog device. |
| 70 | * @ping: The routine that sends a keepalive ping to the watchdog device. | 70 | * @ping: The routine that sends a keepalive ping to the watchdog device. |
| 71 | * @status: The routine that shows the status of the watchdog device. | ||
| 71 | * | 72 | * |
| 72 | * The watchdog_ops structure contains a list of low-level operations | 73 | * The watchdog_ops structure contains a list of low-level operations |
| 73 | * that control a watchdog device. It also contains the module that owns | 74 | * that control a watchdog device. It also contains the module that owns |
| @@ -81,12 +82,14 @@ struct watchdog_ops { | |||
| 81 | int (*stop)(struct watchdog_device *); | 82 | int (*stop)(struct watchdog_device *); |
| 82 | /* optional operations */ | 83 | /* optional operations */ |
| 83 | int (*ping)(struct watchdog_device *); | 84 | int (*ping)(struct watchdog_device *); |
| 85 | unsigned int (*status)(struct watchdog_device *); | ||
| 84 | }; | 86 | }; |
| 85 | 87 | ||
| 86 | /** struct watchdog_device - The structure that defines a watchdog device | 88 | /** struct watchdog_device - The structure that defines a watchdog device |
| 87 | * | 89 | * |
| 88 | * @info: Pointer to a watchdog_info structure. | 90 | * @info: Pointer to a watchdog_info structure. |
| 89 | * @ops: Pointer to the list of watchdog operations. | 91 | * @ops: Pointer to the list of watchdog operations. |
| 92 | * @bootstatus: Status of the watchdog device at boot. | ||
| 90 | * @driver-data:Pointer to the drivers private data. | 93 | * @driver-data:Pointer to the drivers private data. |
| 91 | * @status: Field that contains the devices internal status bits. | 94 | * @status: Field that contains the devices internal status bits. |
| 92 | * | 95 | * |
| @@ -99,6 +102,7 @@ struct watchdog_ops { | |||
| 99 | struct watchdog_device { | 102 | struct watchdog_device { |
| 100 | const struct watchdog_info *info; | 103 | const struct watchdog_info *info; |
| 101 | const struct watchdog_ops *ops; | 104 | const struct watchdog_ops *ops; |
| 105 | unsigned int bootstatus; | ||
| 102 | void *driver_data; | 106 | void *driver_data; |
| 103 | unsigned long status; | 107 | unsigned long status; |
| 104 | /* Bit numbers for status flags */ | 108 | /* Bit numbers for status flags */ |
