Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d63c134 authored by Timur Tabi's avatar Timur Tabi Committed by Wim Van Sebroeck
Browse files

watchdog: add CONFIG_WATCHDOG_NOWAYOUT support to PowerPC Book-E watchdog driver



Normally, the watchdog is disabled when dev/watchdog is closed, but if
CONFIG_WATCHDOG_NOWAYOUT is defined, then it means that the watchdog should
remain enabled.  So we should disable it only if CONFIG_WATCHDOG_NOWAYOUT is
not defined.

Also ensure that /dev/watchdog is only opened by one process at a time.  That
way, a second process can't accidentally disable the watchdog while the first
process has it open.  There shouldn't be any need for more than one process to
open /dev/watchdog anyway.

Signed-off-by: default avatarTimur Tabi <timur@freescale.com>
Acked-by: default avatarJosh Boyer <jwboyer@linux.vnet.ibm.com>
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent a787e710
Loading
Loading
Loading
Loading
+16 −0
Original line number Original line Diff line number Diff line
@@ -193,8 +193,15 @@ static long booke_wdt_ioctl(struct file *file,
	return 0;
	return 0;
}
}


/* wdt_is_active stores wether or not the /dev/watchdog device is opened */
static unsigned long wdt_is_active;

static int booke_wdt_open(struct inode *inode, struct file *file)
static int booke_wdt_open(struct inode *inode, struct file *file)
{
{
	/* /dev/watchdog can only be opened once */
	if (test_and_set_bit(0, &wdt_is_active))
		return -EBUSY;

	spin_lock(&booke_wdt_lock);
	spin_lock(&booke_wdt_lock);
	if (booke_wdt_enabled == 0) {
	if (booke_wdt_enabled == 0) {
		booke_wdt_enabled = 1;
		booke_wdt_enabled = 1;
@@ -210,8 +217,17 @@ static int booke_wdt_open(struct inode *inode, struct file *file)


static int booke_wdt_release(struct inode *inode, struct file *file)
static int booke_wdt_release(struct inode *inode, struct file *file)
{
{
#ifndef CONFIG_WATCHDOG_NOWAYOUT
	/* Normally, the watchdog is disabled when /dev/watchdog is closed, but
	 * if CONFIG_WATCHDOG_NOWAYOUT is defined, then it means that the
	 * watchdog should remain enabled.  So we disable it only if
	 * CONFIG_WATCHDOG_NOWAYOUT is not defined.
	 */
	on_each_cpu(__booke_wdt_disable, NULL, 0);
	on_each_cpu(__booke_wdt_disable, NULL, 0);
	booke_wdt_enabled = 0;
	booke_wdt_enabled = 0;
#endif

	clear_bit(0, &wdt_is_active);


	return 0;
	return 0;
}
}