* [PATCH] Add WDIOC_GETTIMELEFT ioctl support to w83627 watchdog driver
@ 2011-09-12 5:10 Greg Lee
2011-09-12 9:05 ` Pádraig Brady
0 siblings, 1 reply; 2+ messages in thread
From: Greg Lee @ 2011-09-12 5:10 UTC (permalink / raw)
To: linux-watchdog, linux-kernel
Add WDIOC_GETTIMELEFT ioctl allowing you to check how much time is left
on the watchdog counter before a reset occurs.
Signed-off-by: Greg Lee <glee [at] swspec.com>
---
--- linux-3.1-rc5.orig/drivers/watchdog/w83627hf_wdt.c
+++ linux-3.1-rc5.mine/drivers/watchdog/w83627hf_wdt.c
@@ -176,6 +176,23 @@ static int wdt_set_heartbeat(int t)
return 0;
}
+static int wdt_get_time_left(void){
+ int timeleft;
+
+ spin_lock(&io_lock);
+
+ w83627hf_select_wd_register();
+
+ outb_p(0xF6, WDT_EFER); /* Select CRF6 */
+ timeleft = inb_p(WDT_EFDR); /* Read Timeout counter to CRF6 */
+
+ w83627hf_unselect_wd_register();
+
+ spin_unlock(&io_lock);
+
+ return timeleft;
+}
+
static ssize_t wdt_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
@@ -202,7 +219,7 @@ static long wdt_ioctl(struct file *file,
{
void __user *argp = (void __user *)arg;
int __user *p = argp;
- int new_timeout;
+ int timeval;
static const struct watchdog_info ident = {
.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
WDIOF_MAGICCLOSE,
@@ -238,14 +255,17 @@ static long wdt_ioctl(struct file *file,
wdt_ping();
break;
case WDIOC_SETTIMEOUT:
- if (get_user(new_timeout, p))
+ if (get_user(timeval, p))
return -EFAULT;
- if (wdt_set_heartbeat(new_timeout))
+ if (wdt_set_heartbeat(timeval))
return -EINVAL;
wdt_ping();
/* Fall */
case WDIOC_GETTIMEOUT:
return put_user(timeout, p);
+ case WDIOC_GETTIMELEFT:
+ timeval = wdt_get_time_left();
+ return put_user(timeval, p);
default:
return -ENOTTY;
}
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] Add WDIOC_GETTIMELEFT ioctl support to w83627 watchdog driver
2011-09-12 5:10 [PATCH] Add WDIOC_GETTIMELEFT ioctl support to w83627 watchdog driver Greg Lee
@ 2011-09-12 9:05 ` Pádraig Brady
0 siblings, 0 replies; 2+ messages in thread
From: Pádraig Brady @ 2011-09-12 9:05 UTC (permalink / raw)
To: Greg Lee; +Cc: linux-watchdog, linux-kernel
On 09/12/2011 06:10 AM, Greg Lee wrote:
> Add WDIOC_GETTIMELEFT ioctl allowing you to check how much time is left
> on the watchdog counter before a reset occurs.
>
> Signed-off-by: Greg Lee <glee [at] swspec.com>
>
> ---
> --- linux-3.1-rc5.orig/drivers/watchdog/w83627hf_wdt.c
> +++ linux-3.1-rc5.mine/drivers/watchdog/w83627hf_wdt.c
> @@ -176,6 +176,23 @@ static int wdt_set_heartbeat(int t)
> return 0;
> }
>
> +static int wdt_get_time_left(void){
Thanks for this.
Please put the { on the next line.
s/wdt_ctrl/wdt_set_time/
s/wdt_get_time_left/wdt_get_time/
cheers,
Pádraig.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-09-12 9:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-12 5:10 [PATCH] Add WDIOC_GETTIMELEFT ioctl support to w83627 watchdog driver Greg Lee
2011-09-12 9:05 ` Pádraig Brady
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox