diff options
author | Viresh Kumar <viresh.kumar@st.com> | 2012-03-16 04:14:00 -0400 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2012-03-27 14:15:37 -0400 |
commit | fd7b673c92731fc6c0b1e999adfd87b6762ee797 (patch) | |
tree | 35fafd733a2846acb1dd7a06cb7078a7fe59086f | |
parent | 2ca1606359695cc7ce371c7829c4082d9095fc06 (diff) |
watchdog: Add support for WDIOC_GETTIMELEFT IOCTL in watchdog core
This patch adds support for WDIOC_GETTIMELEFT IOCTL in watchdog core. So, there
is another function pointer added to struct watchdog_ops, which can be passed by
drivers to support this IOCTL.
Related documentation is updated too.
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
-rw-r--r-- | Documentation/watchdog/convert_drivers_to_kernel_api.txt | 4 | ||||
-rw-r--r-- | Documentation/watchdog/watchdog-kernel-api.txt | 4 | ||||
-rw-r--r-- | drivers/watchdog/watchdog_dev.c | 5 | ||||
-rw-r--r-- | include/linux/watchdog.h | 2 |
4 files changed, 14 insertions, 1 deletions
diff --git a/Documentation/watchdog/convert_drivers_to_kernel_api.txt b/Documentation/watchdog/convert_drivers_to_kernel_api.txt index be8119bb15d2..271b8850dde7 100644 --- a/Documentation/watchdog/convert_drivers_to_kernel_api.txt +++ b/Documentation/watchdog/convert_drivers_to_kernel_api.txt | |||
@@ -59,6 +59,10 @@ Here is a overview of the functions and probably needed actions: | |||
59 | WDIOC_GETTIMEOUT: | 59 | WDIOC_GETTIMEOUT: |
60 | No preparations needed | 60 | No preparations needed |
61 | 61 | ||
62 | WDIOC_GETTIMELEFT: | ||
63 | It needs get_timeleft() callback to be defined. Otherwise it | ||
64 | will return EOPNOTSUPP | ||
65 | |||
62 | Other IOCTLs can be served using the ioctl-callback. Note that this is mainly | 66 | Other IOCTLs can be served using the ioctl-callback. Note that this is mainly |
63 | intended for porting old drivers; new drivers should not invent private IOCTLs. | 67 | intended for porting old drivers; new drivers should not invent private IOCTLs. |
64 | Private IOCTLs are processed first. When the callback returns with | 68 | Private IOCTLs are processed first. When the callback returns with |
diff --git a/Documentation/watchdog/watchdog-kernel-api.txt b/Documentation/watchdog/watchdog-kernel-api.txt index 7d9d1da762b6..227f6cd0e5fa 100644 --- a/Documentation/watchdog/watchdog-kernel-api.txt +++ b/Documentation/watchdog/watchdog-kernel-api.txt | |||
@@ -1,6 +1,6 @@ | |||
1 | The Linux WatchDog Timer Driver Core kernel API. | 1 | The Linux WatchDog Timer Driver Core kernel API. |
2 | =============================================== | 2 | =============================================== |
3 | Last reviewed: 29-Nov-2011 | 3 | Last reviewed: 16-Mar-2012 |
4 | 4 | ||
5 | Wim Van Sebroeck <wim@iguana.be> | 5 | Wim Van Sebroeck <wim@iguana.be> |
6 | 6 | ||
@@ -77,6 +77,7 @@ struct watchdog_ops { | |||
77 | int (*ping)(struct watchdog_device *); | 77 | int (*ping)(struct watchdog_device *); |
78 | unsigned int (*status)(struct watchdog_device *); | 78 | unsigned int (*status)(struct watchdog_device *); |
79 | int (*set_timeout)(struct watchdog_device *, unsigned int); | 79 | int (*set_timeout)(struct watchdog_device *, unsigned int); |
80 | unsigned int (*get_timeleft)(struct watchdog_device *); | ||
80 | long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long); | 81 | long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long); |
81 | }; | 82 | }; |
82 | 83 | ||
@@ -123,6 +124,7 @@ they are supported. These optional routines/operations are: | |||
123 | because the watchdog does not necessarily has a 1 second resolution). | 124 | because the watchdog does not necessarily has a 1 second resolution). |
124 | (Note: the WDIOF_SETTIMEOUT needs to be set in the options field of the | 125 | (Note: the WDIOF_SETTIMEOUT needs to be set in the options field of the |
125 | watchdog's info structure). | 126 | watchdog's info structure). |
127 | * get_timeleft: this routines returns the time that's left before a reset. | ||
126 | * ioctl: if this routine is present then it will be called first before we do | 128 | * ioctl: if this routine is present then it will be called first before we do |
127 | our own internal ioctl call handling. This routine should return -ENOIOCTLCMD | 129 | our own internal ioctl call handling. This routine should return -ENOIOCTLCMD |
128 | if a command is not supported. The parameters that are passed to the ioctl | 130 | if a command is not supported. The parameters that are passed to the ioctl |
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index c6e1b8dd80cc..8558da912c42 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c | |||
@@ -236,6 +236,11 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd, | |||
236 | if (wdd->timeout == 0) | 236 | if (wdd->timeout == 0) |
237 | return -EOPNOTSUPP; | 237 | return -EOPNOTSUPP; |
238 | return put_user(wdd->timeout, p); | 238 | return put_user(wdd->timeout, p); |
239 | case WDIOC_GETTIMELEFT: | ||
240 | if (!wdd->ops->get_timeleft) | ||
241 | return -EOPNOTSUPP; | ||
242 | |||
243 | return put_user(wdd->ops->get_timeleft(wdd), p); | ||
239 | default: | 244 | default: |
240 | return -ENOTTY; | 245 | return -ENOTTY; |
241 | } | 246 | } |
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h index de75167093bf..ac40716b44e9 100644 --- a/include/linux/watchdog.h +++ b/include/linux/watchdog.h | |||
@@ -66,6 +66,7 @@ struct watchdog_device; | |||
66 | * @ping: The routine that sends a keepalive ping to the watchdog device. | 66 | * @ping: The routine that sends a keepalive ping to the watchdog device. |
67 | * @status: The routine that shows the status of the watchdog device. | 67 | * @status: The routine that shows the status of the watchdog device. |
68 | * @set_timeout:The routine for setting the watchdog devices timeout value. | 68 | * @set_timeout:The routine for setting the watchdog devices timeout value. |
69 | * @get_timeleft:The routine that get's the time that's left before a reset. | ||
69 | * @ioctl: The routines that handles extra ioctl calls. | 70 | * @ioctl: The routines that handles extra ioctl calls. |
70 | * | 71 | * |
71 | * The watchdog_ops structure contains a list of low-level operations | 72 | * The watchdog_ops structure contains a list of low-level operations |
@@ -82,6 +83,7 @@ struct watchdog_ops { | |||
82 | int (*ping)(struct watchdog_device *); | 83 | int (*ping)(struct watchdog_device *); |
83 | unsigned int (*status)(struct watchdog_device *); | 84 | unsigned int (*status)(struct watchdog_device *); |
84 | int (*set_timeout)(struct watchdog_device *, unsigned int); | 85 | int (*set_timeout)(struct watchdog_device *, unsigned int); |
86 | unsigned int (*get_timeleft)(struct watchdog_device *); | ||
85 | long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long); | 87 | long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long); |
86 | }; | 88 | }; |
87 | 89 | ||