[PATCH v2 3/3] watchdog: max63xx: add heartbeat to platform data
From: Vivien Didelot
Date: Wed Jun 17 2015 - 18:59:27 EST
Actually, there is no way but the module parameter to set the desired
heartbeat. This patch allows a platform code to set it in the device
platform data. This is convenient for platforms and built-in drivers.
To do so, initialize heartbeat to zero to allow the module parameter to
take precedence over the platform setting. If not set, it will still
default to DEFAULT_HEARTBEAT.
Signed-off-by: Vivien Didelot <vivien.didelot@xxxxxxxxxxxxxxxxxxxx>
---
drivers/watchdog/max63xx_wdt.c | 6 +++++-
include/linux/platform_data/max63xx_wdt.h | 2 ++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/watchdog/max63xx_wdt.c b/drivers/watchdog/max63xx_wdt.c
index cce2b12..e49ecd9 100644
--- a/drivers/watchdog/max63xx_wdt.c
+++ b/drivers/watchdog/max63xx_wdt.c
@@ -31,7 +31,7 @@
#define DEFAULT_HEARTBEAT 60
#define MAX_HEARTBEAT 60
-static unsigned int heartbeat = DEFAULT_HEARTBEAT;
+static unsigned int heartbeat;
static bool nowayout = WATCHDOG_NOWAYOUT;
/*
@@ -260,6 +260,10 @@ static int max63xx_wdt_probe(struct platform_device *pdev)
wdt->pdata = dev_get_platdata(&pdev->dev);
+ /* The module parameter takes precedence over the platform data */
+ if (!heartbeat && wdt->pdata && wdt->pdata->heartbeat)
+ heartbeat = wdt->pdata->heartbeat;
+
if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT)
heartbeat = DEFAULT_HEARTBEAT;
diff --git a/include/linux/platform_data/max63xx_wdt.h b/include/linux/platform_data/max63xx_wdt.h
index ae28024..8127b1a 100644
--- a/include/linux/platform_data/max63xx_wdt.h
+++ b/include/linux/platform_data/max63xx_wdt.h
@@ -14,12 +14,14 @@
/**
* struct max63xx_platform_data - MAX63xx connectivity info
+ * @heartbeat: Watchdog heartbeat period in seconds.
* @wdi: Watchdog Input GPIO number.
* @set0: Watchdog SET0 GPIO number.
* @set1: Watchdog SET1 GPIO number.
* @set2: Watchdog SET2 GPIO number.
*/
struct max63xx_platform_data {
+ unsigned int heartbeat;
unsigned int wdi;
unsigned int set0, set1, set2;
};
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/