watchdog:use 'V' to stop watchdog
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
parent
35c1e53b1a
commit
96ec6983db
@ -354,6 +354,12 @@ config WATCHDOG_DEVPATH
|
||||
Please, check how your specific chip or board uses this symbol.
|
||||
FYI: It's NOT used by the Auto-monitor feature.
|
||||
|
||||
config CONFIG_WATCHDOG_MAGIC_V
|
||||
bool "Watchdog Device Magic num"
|
||||
default Y
|
||||
---help---
|
||||
The watchdog can be stopped by writing 'V' to the watchdog's device node
|
||||
|
||||
menuconfig WATCHDOG_AUTOMONITOR
|
||||
bool "Auto-monitor"
|
||||
---help---
|
||||
|
@ -436,7 +436,48 @@ static ssize_t wdog_read(FAR struct file *filep, FAR char *buffer,
|
||||
static ssize_t wdog_write(FAR struct file *filep, FAR const char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
return 0;
|
||||
#ifdef CONFIG_WATCHDOG_MAGIC_V
|
||||
FAR struct inode *inode = filep->f_inode;
|
||||
FAR struct watchdog_upperhalf_s *upper;
|
||||
FAR struct watchdog_lowerhalf_s *lower;
|
||||
int err = 0;
|
||||
int i;
|
||||
|
||||
upper = inode->i_private;
|
||||
DEBUGASSERT(upper != NULL);
|
||||
lower = upper->lower;
|
||||
DEBUGASSERT(lower != NULL);
|
||||
|
||||
nxmutex_lock(&upper->lock);
|
||||
|
||||
for (i = 0; i < buflen; i++)
|
||||
{
|
||||
if (buffer[i] == 'V')
|
||||
{
|
||||
#ifdef CONFIG_WATCHDOG_AUTOMONITOR
|
||||
watchdog_automonitor_stop(upper);
|
||||
#else
|
||||
err = lower->ops->stop(lower);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == buflen)
|
||||
{
|
||||
err = lower->ops->keepalive(lower);
|
||||
}
|
||||
|
||||
nxmutex_unlock(&upper->lock);
|
||||
|
||||
if (err < 0)
|
||||
{
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return buflen;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user