Source
x
pr_err("margin must be in range 31 - 255 seconds, you tried to set %d\n",
/*
* Watchdog driver for SBC-FITPC2 board
*
* Author: Denis Turischev <denis@compulab.co.il>
*
* Adapted from the IXP2000 watchdog driver by Deepak Saxena.
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/
static bool nowayout = WATCHDOG_NOWAYOUT;
static unsigned int margin = 60; /* (secs) Default is 1 minute */
static unsigned long wdt_status;
static DEFINE_MUTEX(wdt_lock);
static void wdt_send_data(unsigned char command, unsigned char data)
{
outb(data, DATA_PORT);
msleep(200);
outb(command, COMMAND_PORT);
msleep(100);
}
static void wdt_enable(void)
{
mutex_lock(&wdt_lock);
wdt_send_data(IFACE_ON_COMMAND, 1);
wdt_send_data(REBOOT_COMMAND, margin);
mutex_unlock(&wdt_lock);
}
static void wdt_disable(void)
{
mutex_lock(&wdt_lock);
wdt_send_data(IFACE_ON_COMMAND, 0);
wdt_send_data(REBOOT_COMMAND, 0);
mutex_unlock(&wdt_lock);
}
static int fitpc2_wdt_open(struct inode *inode, struct file *file)
{
if (test_and_set_bit(WDT_IN_USE, &wdt_status))
return -EBUSY;
clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
wdt_enable();
return nonseekable_open(inode, file);
}
static ssize_t fitpc2_wdt_write(struct file *file, const char *data,
size_t len, loff_t *ppos)
{
size_t i;
if (!len)
return 0;
if (nowayout) {
len = 0;
goto out;
}