diff options
author | Wim Van Sebroeck <wim@iguana.be> | 2011-07-22 14:59:49 -0400 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2011-07-28 04:01:16 -0400 |
commit | 78d88fc01202b088573c962e2885556a5e99bf74 (patch) | |
tree | 8f5650e80988752d144c4575ae4d2b4e846e2aa5 | |
parent | 7e192b9c4234d29bdc20ac8d0a67edf7624b4206 (diff) |
watchdog: WatchDog Timer Driver Core - Add ioctl call
Add support for extra ioctl calls by adding a
ioctl watchdog operation. This operation will be
called before we do our own handling of ioctl
commands. This way we can override the internal
ioctl command handling and we can also add
extra ioctl commands. The ioctl watchdog operation
should return the appropriate error codes or
-ENOIOCTLCMD if the ioctl command should be handled
through the internal ioctl handling of the framework.
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>
-rw-r--r-- | Documentation/watchdog/watchdog-kernel-api.txt | 5 | ||||
-rw-r--r-- | drivers/watchdog/watchdog_dev.c | 6 | ||||
-rw-r--r-- | include/linux/watchdog.h | 2 |
3 files changed, 13 insertions, 0 deletions
diff --git a/Documentation/watchdog/watchdog-kernel-api.txt b/Documentation/watchdog/watchdog-kernel-api.txt index 785fa0c996a4..829955bd245e 100644 --- a/Documentation/watchdog/watchdog-kernel-api.txt +++ b/Documentation/watchdog/watchdog-kernel-api.txt | |||
@@ -73,6 +73,7 @@ struct watchdog_ops { | |||
73 | int (*ping)(struct watchdog_device *); | 73 | int (*ping)(struct watchdog_device *); |
74 | unsigned int (*status)(struct watchdog_device *); | 74 | unsigned int (*status)(struct watchdog_device *); |
75 | int (*set_timeout)(struct watchdog_device *, unsigned int); | 75 | int (*set_timeout)(struct watchdog_device *, unsigned int); |
76 | long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long); | ||
76 | }; | 77 | }; |
77 | 78 | ||
78 | It is important that you first define the module owner of the watchdog timer | 79 | It is important that you first define the module owner of the watchdog timer |
@@ -117,6 +118,10 @@ they are supported. These optional routines/operations are: | |||
117 | to re-program the watchdog timer device. | 118 | to re-program the watchdog timer device. |
118 | (Note: the WDIOF_SETTIMEOUT needs to be set in the options field of the | 119 | (Note: the WDIOF_SETTIMEOUT needs to be set in the options field of the |
119 | watchdog's info structure). | 120 | watchdog's info structure). |
121 | * ioctl: if this routine is present then it will be called first before we do | ||
122 | our own internal ioctl call handling. This routine should return -ENOIOCTLCMD | ||
123 | if a command is not supported. The parameters that are passed to the ioctl | ||
124 | call are: watchdog_device, cmd and arg. | ||
120 | 125 | ||
121 | The status bits should (preferably) be set with the set_bit and clear_bit alike | 126 | The status bits should (preferably) be set with the set_bit and clear_bit alike |
122 | bit-operations. The status bits that are defined are: | 127 | bit-operations. The status bits that are defined are: |
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index ac20f92347b1..e7134a5979c6 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c | |||
@@ -180,6 +180,12 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd, | |||
180 | unsigned int val; | 180 | unsigned int val; |
181 | int err; | 181 | int err; |
182 | 182 | ||
183 | if (wdd->ops->ioctl) { | ||
184 | err = wdd->ops->ioctl(wdd, cmd, arg); | ||
185 | if (err != -ENOIOCTLCMD) | ||
186 | return err; | ||
187 | } | ||
188 | |||
183 | switch (cmd) { | 189 | switch (cmd) { |
184 | case WDIOC_GETSUPPORT: | 190 | case WDIOC_GETSUPPORT: |
185 | return copy_to_user(argp, wdd->info, | 191 | return copy_to_user(argp, wdd->info, |
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h index f719883c5141..325d90b6641b 100644 --- a/include/linux/watchdog.h +++ b/include/linux/watchdog.h | |||
@@ -70,6 +70,7 @@ struct 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 | * @set_timeout:The routine for setting the watchdog devices timeout value. |
73 | * @ioctl: The routines that handles extra ioctl calls. | ||
73 | * | 74 | * |
74 | * The watchdog_ops structure contains a list of low-level operations | 75 | * The watchdog_ops structure contains a list of low-level operations |
75 | * that control a watchdog device. It also contains the module that owns | 76 | * that control a watchdog device. It also contains the module that owns |
@@ -85,6 +86,7 @@ struct watchdog_ops { | |||
85 | int (*ping)(struct watchdog_device *); | 86 | int (*ping)(struct watchdog_device *); |
86 | unsigned int (*status)(struct watchdog_device *); | 87 | unsigned int (*status)(struct watchdog_device *); |
87 | int (*set_timeout)(struct watchdog_device *, unsigned int); | 88 | int (*set_timeout)(struct watchdog_device *, unsigned int); |
89 | long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long); | ||
88 | }; | 90 | }; |
89 | 91 | ||
90 | /** struct watchdog_device - The structure that defines a watchdog device | 92 | /** struct watchdog_device - The structure that defines a watchdog device |