diff options
| -rw-r--r-- | Documentation/watchdog/watchdog-kernel-api.txt | 10 | ||||
| -rw-r--r-- | drivers/watchdog/watchdog_dev.c | 20 | ||||
| -rw-r--r-- | include/linux/watchdog.h | 4 |
3 files changed, 34 insertions, 0 deletions
diff --git a/Documentation/watchdog/watchdog-kernel-api.txt b/Documentation/watchdog/watchdog-kernel-api.txt index 429f81bf0cf7..acdee39fb08a 100644 --- a/Documentation/watchdog/watchdog-kernel-api.txt +++ b/Documentation/watchdog/watchdog-kernel-api.txt | |||
| @@ -42,6 +42,7 @@ 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 | unsigned int bootstatus; |
| 45 | unsigned int timeout; | ||
| 45 | void *driver_data; | 46 | void *driver_data; |
| 46 | unsigned long status; | 47 | unsigned long status; |
| 47 | }; | 48 | }; |
| @@ -50,6 +51,7 @@ It contains following fields: | |||
| 50 | * info: a pointer to a watchdog_info structure. This structure gives some | 51 | * info: a pointer to a watchdog_info structure. This structure gives some |
| 51 | additional information about the watchdog timer itself. (Like it's unique name) | 52 | additional information about the watchdog timer itself. (Like it's unique name) |
| 52 | * ops: a pointer to the list of watchdog operations that the watchdog supports. | 53 | * ops: a pointer to the list of watchdog operations that the watchdog supports. |
| 54 | * timeout: the watchdog timer's timeout value (in seconds). | ||
| 53 | * bootstatus: status of the device after booting (reported with watchdog | 55 | * bootstatus: status of the device after booting (reported with watchdog |
| 54 | WDIOF_* status bits). | 56 | WDIOF_* status bits). |
| 55 | * driver_data: a pointer to the drivers private data of a watchdog device. | 57 | * driver_data: a pointer to the drivers private data of a watchdog device. |
| @@ -70,6 +72,7 @@ struct watchdog_ops { | |||
| 70 | /* optional operations */ | 72 | /* optional operations */ |
| 71 | int (*ping)(struct watchdog_device *); | 73 | int (*ping)(struct watchdog_device *); |
| 72 | unsigned int (*status)(struct watchdog_device *); | 74 | unsigned int (*status)(struct watchdog_device *); |
| 75 | int (*set_timeout)(struct watchdog_device *, unsigned int); | ||
| 73 | }; | 76 | }; |
| 74 | 77 | ||
| 75 | It is important that you first define the module owner of the watchdog timer | 78 | It is important that you first define the module owner of the watchdog timer |
| @@ -107,6 +110,13 @@ they are supported. These optional routines/operations are: | |||
| 107 | info structure). | 110 | info structure). |
| 108 | * status: this routine checks the status of the watchdog timer device. The | 111 | * status: this routine checks the status of the watchdog timer device. The |
| 109 | status of the device is reported with watchdog WDIOF_* status flags/bits. | 112 | status of the device is reported with watchdog WDIOF_* status flags/bits. |
| 113 | * set_timeout: this routine checks and changes the timeout of the watchdog | ||
| 114 | timer device. It returns 0 on success, -EINVAL for "parameter out of range" | ||
| 115 | and -EIO for "could not write value to the watchdog". On success the timeout | ||
| 116 | value of the watchdog_device will be changed to the value that was just used | ||
| 117 | to re-program the watchdog timer device. | ||
| 118 | (Note: the WDIOF_SETTIMEOUT needs to be set in the options field of the | ||
| 119 | watchdog's info structure). | ||
| 110 | 120 | ||
| 111 | The status bits should (preferably) be set with the set_bit and clear_bit alike | 121 | The status bits should (preferably) be set with the set_bit and clear_bit alike |
| 112 | bit-operations. The status bits that are defined are: | 122 | bit-operations. The status bits that are defined are: |
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index 9f5550e16ab5..2c0289deaadd 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c | |||
| @@ -190,6 +190,26 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd, | |||
| 190 | return -EOPNOTSUPP; | 190 | return -EOPNOTSUPP; |
| 191 | watchdog_ping(wdd); | 191 | watchdog_ping(wdd); |
| 192 | return 0; | 192 | return 0; |
| 193 | case WDIOC_SETTIMEOUT: | ||
| 194 | if ((wdd->ops->set_timeout == NULL) || | ||
| 195 | !(wdd->info->options & WDIOF_SETTIMEOUT)) | ||
| 196 | return -EOPNOTSUPP; | ||
| 197 | if (get_user(val, p)) | ||
| 198 | return -EFAULT; | ||
| 199 | err = wdd->ops->set_timeout(wdd, val); | ||
| 200 | if (err < 0) | ||
| 201 | return err; | ||
| 202 | wdd->timeout = val; | ||
| 203 | /* If the watchdog is active then we send a keepalive ping | ||
| 204 | * to make sure that the watchdog keep's running (and if | ||
| 205 | * possible that it takes the new timeout) */ | ||
| 206 | watchdog_ping(wdd); | ||
| 207 | /* Fall */ | ||
| 208 | case WDIOC_GETTIMEOUT: | ||
| 209 | /* timeout == 0 means that we don't know the timeout */ | ||
| 210 | if (wdd->timeout == 0) | ||
| 211 | return -EOPNOTSUPP; | ||
| 212 | return put_user(wdd->timeout, p); | ||
| 193 | default: | 213 | default: |
| 194 | return -ENOTTY; | 214 | return -ENOTTY; |
| 195 | } | 215 | } |
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h index db46fe89563e..9f33efe199d1 100644 --- a/include/linux/watchdog.h +++ b/include/linux/watchdog.h | |||
| @@ -69,6 +69,7 @@ struct 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 | * @status: The routine that shows the status of the watchdog device. |
| 72 | * @set_timeout:The routine for setting the watchdog devices timeout value. | ||
| 72 | * | 73 | * |
| 73 | * The watchdog_ops structure contains a list of low-level operations | 74 | * The watchdog_ops structure contains a list of low-level operations |
| 74 | * that control a watchdog device. It also contains the module that owns | 75 | * that control a watchdog device. It also contains the module that owns |
| @@ -83,6 +84,7 @@ struct watchdog_ops { | |||
| 83 | /* optional operations */ | 84 | /* optional operations */ |
| 84 | int (*ping)(struct watchdog_device *); | 85 | int (*ping)(struct watchdog_device *); |
| 85 | unsigned int (*status)(struct watchdog_device *); | 86 | unsigned int (*status)(struct watchdog_device *); |
| 87 | int (*set_timeout)(struct watchdog_device *, unsigned int); | ||
| 86 | }; | 88 | }; |
| 87 | 89 | ||
| 88 | /** struct watchdog_device - The structure that defines a watchdog device | 90 | /** struct watchdog_device - The structure that defines a watchdog device |
| @@ -90,6 +92,7 @@ struct watchdog_ops { | |||
| 90 | * @info: Pointer to a watchdog_info structure. | 92 | * @info: Pointer to a watchdog_info structure. |
| 91 | * @ops: Pointer to the list of watchdog operations. | 93 | * @ops: Pointer to the list of watchdog operations. |
| 92 | * @bootstatus: Status of the watchdog device at boot. | 94 | * @bootstatus: Status of the watchdog device at boot. |
| 95 | * @timeout: The watchdog devices timeout value. | ||
| 93 | * @driver-data:Pointer to the drivers private data. | 96 | * @driver-data:Pointer to the drivers private data. |
| 94 | * @status: Field that contains the devices internal status bits. | 97 | * @status: Field that contains the devices internal status bits. |
| 95 | * | 98 | * |
| @@ -103,6 +106,7 @@ struct watchdog_device { | |||
| 103 | const struct watchdog_info *info; | 106 | const struct watchdog_info *info; |
| 104 | const struct watchdog_ops *ops; | 107 | const struct watchdog_ops *ops; |
| 105 | unsigned int bootstatus; | 108 | unsigned int bootstatus; |
| 109 | unsigned int timeout; | ||
| 106 | void *driver_data; | 110 | void *driver_data; |
| 107 | unsigned long status; | 111 | unsigned long status; |
| 108 | /* Bit numbers for status flags */ | 112 | /* Bit numbers for status flags */ |
