/* * Close the watchdog device. * If CONFIG_WATCHDOG_NOWAYOUT is NOT defined then the watchdog is also * disabled.
*/ staticint at91_wdt_close(struct inode *inode, struct file *file)
{ /* Disable the watchdog when file is closed */ if (!nowayout)
at91_wdt_stop();
clear_bit(0, &at91wdt_busy); return 0;
}
/* * Change the watchdog time interval.
*/ staticint at91_wdt_settimeout(int new_time)
{ /* * All counting occurs at SLOW_CLOCK / 128 = 256 Hz * * Since WDV is a 16-bit counter, the maximum period is * 65536 / 256 = 256 seconds.
*/ if ((new_time <= 0) || (new_time > WDT_MAX_TIME)) return -EINVAL;
/* Set new watchdog time. It will be used when
at91_wdt_start() is called. */
wdt_time = new_time; return 0;
}
/* * Handle commands from user-space.
*/ staticlong at91_wdt_ioctl(struct file *file, unsignedint cmd, unsignedlong arg)
{ void __user *argp = (void __user *)arg; int __user *p = argp; int new_value;
switch (cmd) { case WDIOC_GETSUPPORT: return copy_to_user(argp, &at91_wdt_info, sizeof(at91_wdt_info)) ? -EFAULT : 0; case WDIOC_GETSTATUS: case WDIOC_GETBOOTSTATUS: return put_user(0, p); case WDIOC_SETOPTIONS: if (get_user(new_value, p)) return -EFAULT; if (new_value & WDIOS_DISABLECARD)
at91_wdt_stop(); if (new_value & WDIOS_ENABLECARD)
at91_wdt_start(); return 0; case WDIOC_KEEPALIVE:
at91_wdt_reload(); /* pat the watchdog */ return 0; case WDIOC_SETTIMEOUT: if (get_user(new_value, p)) return -EFAULT; if (at91_wdt_settimeout(new_value)) return -EINVAL; /* Enable new time value */
at91_wdt_start(); /* Return current value */ return put_user(wdt_time, p); case WDIOC_GETTIMEOUT: return put_user(wdt_time, p); default: return -ENOTTY;
}
}
/* * Pat the watchdog whenever device is written to.
*/ static ssize_t at91_wdt_write(struct file *file, constchar *data,
size_t len, loff_t *ppos)
{
at91_wdt_reload(); /* pat the watchdog */ return len;
}
staticint __init at91_wdt_init(void)
{ /* Check that the heartbeat value is within range;
if not reset to the default */ if (at91_wdt_settimeout(wdt_time)) {
at91_wdt_settimeout(WDT_DEFAULT_TIME);
pr_info("wdt_time value must be 1 <= wdt_time <= 256, using %d\n",
wdt_time);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.