Beispiel #1
0
static int __init bfin_wdt_init(void)
{
	int ret;

	stampit();

	/* Check that the timeout value is within range */
	if (bfin_wdt_set_timeout(timeout))
		return -EINVAL;

	/* Since this is an on-chip device and needs no board-specific
	 * resources, we'll handle all the platform device stuff here.
	 */
	ret = platform_driver_register(&bfin_wdt_driver);
	if (ret) {
		pr_init(KERN_ERR PFX "unable to register driver\n");
		return ret;
	}

	bfin_wdt_device = platform_device_register_simple(WATCHDOG_NAME,
								-1, NULL, 0);
	if (IS_ERR(bfin_wdt_device)) {
		pr_init(KERN_ERR PFX "unable to register device\n");
		platform_driver_unregister(&bfin_wdt_driver);
		return PTR_ERR(bfin_wdt_device);
	}

	return 0;
}
static int __init bfin_wdt_init(void)
{
	int ret;

	stampit();

	/*                                              */
	if (bfin_wdt_set_timeout(timeout))
		return -EINVAL;

	/*                                                            
                                                               
  */
	ret = platform_driver_register(&bfin_wdt_driver);
	if (ret) {
		pr_err("unable to register driver\n");
		return ret;
	}

	bfin_wdt_device = platform_device_register_simple(WATCHDOG_NAME,
								-1, NULL, 0);
	if (IS_ERR(bfin_wdt_device)) {
		pr_err("unable to register device\n");
		platform_driver_unregister(&bfin_wdt_driver);
		return PTR_ERR(bfin_wdt_device);
	}

	return 0;
}
Beispiel #3
0
static int bfin_wdt_resume(struct platform_device *pdev)
{
	stampit();

	if (state_before_suspend) {
		bfin_wdt_set_timeout(timeout);
		bfin_wdt_start();
	}

	return 0;
}
Beispiel #4
0
static long bfin_wdt_ioctl(struct file *file,
				unsigned int cmd, unsigned long arg)
{
	void __user *argp = (void __user *)arg;
	int __user *p = argp;

	stampit();

	switch (cmd) {
	case WDIOC_GETSUPPORT:
		if (copy_to_user(argp, &bfin_wdt_info, sizeof(bfin_wdt_info)))
			return -EFAULT;
		else
			return 0;
	case WDIOC_GETSTATUS:
	case WDIOC_GETBOOTSTATUS:
		return put_user(!!(_bfin_swrst & SWRST_RESET_WDOG), p);
	case WDIOC_SETOPTIONS: {
		unsigned long flags;
		int options, ret = -EINVAL;

		if (get_user(options, p))
			return -EFAULT;

		spin_lock_irqsave(&bfin_wdt_spinlock, flags);
		if (options & WDIOS_DISABLECARD) {
			bfin_wdt_stop();
			ret = 0;
		}
		if (options & WDIOS_ENABLECARD) {
			bfin_wdt_start();
			ret = 0;
		}
		spin_unlock_irqrestore(&bfin_wdt_spinlock, flags);
		return ret;
	}
	case WDIOC_KEEPALIVE:
		bfin_wdt_keepalive();
		return 0;
	case WDIOC_SETTIMEOUT: {
		int new_timeout;

		if (get_user(new_timeout, p))
			return -EFAULT;
		if (bfin_wdt_set_timeout(new_timeout))
			return -EINVAL;
	}
	/* Fall */
	case WDIOC_GETTIMEOUT:
		return put_user(timeout, p);
	default:
		return -ENOTTY;
	}
}