[PATCH 2/2] watchdog: gpio: add configurable minimum interval

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add the "min_hw_margin_ms" parameter to gpio_wdt devices, allowing a
minimum interval to be specified, stopping watchdog devices from being
fed too quickly if they require a certain interval between feeds.

Signed-off-by: Isaac True <isaac.true@xxxxxxxxxxxxx>
---
 drivers/watchdog/gpio_wdt.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c
index 0923201ce874..309f66536a14 100644
--- a/drivers/watchdog/gpio_wdt.c
+++ b/drivers/watchdog/gpio_wdt.c
@@ -110,6 +110,7 @@ static int gpio_wdt_probe(struct platform_device *pdev)
 	struct gpio_wdt_priv *priv;
 	enum gpiod_flags gflags;
 	unsigned int hw_margin;
+	unsigned int min_hw_margin;
 	const char *algo;
 	int ret;
 
@@ -144,6 +145,16 @@ static int gpio_wdt_probe(struct platform_device *pdev)
 	if (hw_margin < 2 || hw_margin > 65535)
 		return -EINVAL;
 
+	ret = of_property_read_u32(np, "min_hw_margin_ms", &min_hw_margin);
+	if (ret)
+		min_hw_margin = 0;
+
+	if (min_hw_margin > hw_margin) {
+		dev_err(dev,
+			"Minimum interval cannot be greater than the watchdog interval");
+		return -EINVAL;
+	}
+
 	priv->always_running = of_property_read_bool(np,
 						     "always-running");
 
@@ -152,6 +163,7 @@ static int gpio_wdt_probe(struct platform_device *pdev)
 	priv->wdd.info		= &gpio_wdt_ident;
 	priv->wdd.ops		= &gpio_wdt_ops;
 	priv->wdd.min_timeout	= SOFT_TIMEOUT_MIN;
+	priv->wdd.min_hw_heartbeat_ms = min_hw_margin;
 	priv->wdd.max_hw_heartbeat_ms = hw_margin;
 	priv->wdd.parent	= dev;
 	priv->wdd.timeout	= SOFT_TIMEOUT_DEF;
-- 
2.34.1




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux