[PATCH v1] watchdog: wdat: add param. to start wdog on module insertion

From: Flavio Suligoi
Date: Thu Feb 18 2021 - 13:47:43 EST


Add the parameter "start_enable" to start the watchdog
directly on module insertion.

In an embedded system, for some applications, the watchdog
must be activated as soon as possible.

In some embedded x86 boards the watchdog can be activated
directly by the BIOS (with an appropriate setting of the
BIOS setup). In other cases, when this BIOS feature is not
present, the possibility to start the watchdog immediately
after the module loading can be very useful.

Signed-off-by: Flavio Suligoi <f.suligoi@xxxxxxx>
---
drivers/watchdog/wdat_wdt.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/watchdog/wdat_wdt.c b/drivers/watchdog/wdat_wdt.c
index cec7917790e5..b990d0197d2e 100644
--- a/drivers/watchdog/wdat_wdt.c
+++ b/drivers/watchdog/wdat_wdt.c
@@ -61,6 +61,12 @@ module_param(timeout, int, 0);
MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (default="
__MODULE_STRING(WDAT_DEFAULT_TIMEOUT) ")");

+#define START_DEFAULT 0
+static int start_enabled = START_DEFAULT;
+module_param(start_enabled, int, 0);
+MODULE_PARM_DESC(start_enabled, "Watchdog is started on module insertion "
+ "(default=" __MODULE_STRING(START_DEFAULT) ")");
+
static int wdat_wdt_read(struct wdat_wdt *wdat,
const struct wdat_instruction *instr, u32 *value)
{
@@ -437,6 +443,8 @@ static int wdat_wdt_probe(struct platform_device *pdev)
}

wdat_wdt_boot_status(wdat);
+ if (start_enabled)
+ wdat_wdt_start(&wdat->wdd);
wdat_wdt_set_running(wdat);

ret = wdat_wdt_enable_reboot(wdat);
--
2.25.1