2017-03-06 17:45:04 +01:00
|
|
|
From 76e2b190803484db033153fe8a97b381a567ed25 Mon Sep 17 00:00:00 2001
|
2013-05-10 02:03:39 +02:00
|
|
|
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
|
|
|
|
Date: Wed, 14 Nov 2012 19:16:35 +0800
|
2017-03-06 17:45:04 +01:00
|
|
|
Subject: [PATCH 1/4] watchdog: add keep alive support
|
2013-05-10 02:03:39 +02:00
|
|
|
|
|
|
|
this will allow to ping the watchdog via poller
|
|
|
|
|
|
|
|
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
|
2017-03-06 17:45:04 +01:00
|
|
|
Signed-off-by: Fabio Porcedda <fabio.porcedda@gmail.com>
|
2013-05-10 02:03:39 +02:00
|
|
|
---
|
|
|
|
drivers/watchdog/Kconfig | 1 +
|
2017-03-06 17:45:04 +01:00
|
|
|
drivers/watchdog/wd_core.c | 25 +++++++++++++++++++++++++
|
2013-05-10 02:03:39 +02:00
|
|
|
include/watchdog.h | 2 ++
|
2017-03-06 17:45:04 +01:00
|
|
|
3 files changed, 28 insertions(+)
|
2013-05-10 02:03:39 +02:00
|
|
|
|
|
|
|
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
|
2017-03-06 17:45:04 +01:00
|
|
|
index 63fb1a8c5..7ebff89b9 100644
|
2013-05-10 02:03:39 +02:00
|
|
|
--- a/drivers/watchdog/Kconfig
|
|
|
|
+++ b/drivers/watchdog/Kconfig
|
|
|
|
@@ -4,6 +4,7 @@ config WATCHDOG_IMX_RESET_SOURCE
|
|
|
|
|
|
|
|
menuconfig WATCHDOG
|
|
|
|
bool "Watchdog support"
|
|
|
|
+ select GENERIC_POLLER
|
|
|
|
help
|
|
|
|
Many platforms support a watchdog to keep track of a working machine.
|
|
|
|
This framework provides routines to handle these watchdogs.
|
|
|
|
diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
|
2017-03-06 17:45:04 +01:00
|
|
|
index 3a3f51964..52537afef 100644
|
2013-05-10 02:03:39 +02:00
|
|
|
--- a/drivers/watchdog/wd_core.c
|
|
|
|
+++ b/drivers/watchdog/wd_core.c
|
2017-03-06 17:45:04 +01:00
|
|
|
@@ -18,6 +18,7 @@
|
2013-05-10 02:03:39 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <watchdog.h>
|
|
|
|
+#include <poller.h>
|
|
|
|
|
2017-03-06 17:45:04 +01:00
|
|
|
static LIST_HEAD(watchdog_list);
|
2013-05-10 02:03:39 +02:00
|
|
|
|
2017-03-06 17:45:04 +01:00
|
|
|
@@ -31,6 +32,20 @@ static const char *watchdog_name(struct watchdog *wd)
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
|
|
|
+static struct watchdog *watchdog_get_default(void);
|
|
|
|
+
|
2013-05-10 02:03:39 +02:00
|
|
|
+static void watchdog_poller_func(struct poller_struct *poller)
|
|
|
|
+{
|
2017-03-06 17:45:04 +01:00
|
|
|
+ struct watchdog *wd = watchdog_get_default();
|
|
|
|
+
|
|
|
|
+ if (wd)
|
|
|
|
+ wd->keep_alive(wd);
|
2013-05-10 02:03:39 +02:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static struct poller_struct watchdog_poller = {
|
|
|
|
+ .func = watchdog_poller_func,
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
int watchdog_register(struct watchdog *wd)
|
|
|
|
{
|
2017-03-06 17:45:04 +01:00
|
|
|
if (!wd->priority)
|
|
|
|
@@ -41,6 +56,16 @@ int watchdog_register(struct watchdog *wd)
|
|
|
|
pr_debug("registering watchdog %s with priority %d\n", watchdog_name(wd),
|
|
|
|
wd->priority);
|
2013-05-10 02:03:39 +02:00
|
|
|
|
|
|
|
+
|
2017-03-06 17:45:04 +01:00
|
|
|
+ if (wd->keep_alive) {
|
2013-05-10 02:03:39 +02:00
|
|
|
+ int ret;
|
|
|
|
+
|
|
|
|
+ ret = poller_register(&watchdog_poller);
|
|
|
|
+ if (ret) {
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(watchdog_register);
|
|
|
|
diff --git a/include/watchdog.h b/include/watchdog.h
|
2017-03-06 17:45:04 +01:00
|
|
|
index 3e8a487a4..a2660c2e0 100644
|
2013-05-10 02:03:39 +02:00
|
|
|
--- a/include/watchdog.h
|
|
|
|
+++ b/include/watchdog.h
|
2017-03-06 17:45:04 +01:00
|
|
|
@@ -13,12 +13,14 @@
|
2013-05-10 02:03:39 +02:00
|
|
|
#ifndef INCLUDE_WATCHDOG_H
|
|
|
|
# define INCLUDE_WATCHDOG_H
|
|
|
|
|
|
|
|
+
|
|
|
|
struct watchdog {
|
|
|
|
int (*set_timeout)(struct watchdog *, unsigned);
|
2017-03-06 17:45:04 +01:00
|
|
|
const char *name;
|
|
|
|
struct device_d *dev;
|
|
|
|
unsigned int priority;
|
|
|
|
struct list_head list;
|
2013-05-10 02:03:39 +02:00
|
|
|
+ void (*keep_alive)(struct watchdog *);
|
|
|
|
};
|
|
|
|
|
2017-03-06 17:45:04 +01:00
|
|
|
#ifdef CONFIG_WATCHDOG
|
2013-05-10 02:03:39 +02:00
|
|
|
--
|
2017-03-06 17:45:04 +01:00
|
|
|
2.12.0
|
2013-05-10 02:03:39 +02:00
|
|
|
|