Exemple #1
0
static int mpc5200_wdt_open(struct inode *inode, struct file *file)
{
	
	if (test_and_set_bit(0, &is_active))
		return -EBUSY;

	
	mpc5200_wdt_set_timeout(wdt_global, 30);
	mpc5200_wdt_start(wdt_global);
	file->private_data = wdt_global;
	return nonseekable_open(inode, file);
}
Exemple #2
0
static int mpc5200_wdt_open(struct inode *inode, struct file *file)
{
    /* /dev/watchdog can only be opened once */
    if (test_and_set_bit(0, &is_active))
        return -EBUSY;

    /* Set and activate the watchdog */
    mpc5200_wdt_set_timeout(wdt_global, 30);
    mpc5200_wdt_start(wdt_global);
    file->private_data = wdt_global;
    return nonseekable_open(inode, file);
}
Exemple #3
0
static long mpc5200_wdt_ioctl(struct file *file, unsigned int cmd,
							unsigned long arg)
{
	struct mpc5200_wdt *wdt = file->private_data;
	int __user *data = (int __user *)arg;
	int timeout;
	int ret = 0;

	switch (cmd) {
	case WDIOC_GETSUPPORT:
		ret = copy_to_user(data, &mpc5200_wdt_info,
						sizeof(mpc5200_wdt_info));
		if (ret)
			ret = -EFAULT;
		break;

	case WDIOC_GETSTATUS:
	case WDIOC_GETBOOTSTATUS:
		ret = put_user(0, data);
		break;

	case WDIOC_KEEPALIVE:
		mpc5200_wdt_ping(wdt);
		break;

	case WDIOC_SETTIMEOUT:
		ret = get_user(timeout, data);
		if (ret)
			break;
		mpc5200_wdt_set_timeout(wdt, timeout);
		mpc5200_wdt_start(wdt);
		

	case WDIOC_GETTIMEOUT:
		timeout = mpc5200_wdt_get_timeout(wdt);
		ret = put_user(timeout, data);
		break;

	default:
		ret = -ENOTTY;
	}
	return ret;
}