devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Isaac True <isaac.true@canonical.com>
To: linux-watchdog@vger.kernel.org
Cc: devicetree@vger.kernel.org, wim@linux-watchdog.org,
	linux@roeck-us.net, Isaac True <isaac.true@canonical.com>
Subject: [PATCH 2/2] watchdog: gpio: add configurable minimum interval
Date: Wed, 29 Jun 2022 13:06:26 +0200	[thread overview]
Message-ID: <20220629110626.2158127-2-isaac.true@canonical.com> (raw)
In-Reply-To: <20220629110626.2158127-1-isaac.true@canonical.com>

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@canonical.com>
---
 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


  reply	other threads:[~2022-06-29 11:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-29 11:06 [PATCH 1/2] dt-bindings: watchdog: gpio: add minimum interval Isaac True
2022-06-29 11:06 ` Isaac True [this message]
2022-07-01 17:18   ` [PATCH 2/2] watchdog: gpio: add configurable " Rob Herring
2022-07-01 17:48     ` Guenter Roeck
2022-07-04 11:05       ` Isaac True
2022-07-05 19:56         ` Rob Herring
2022-07-07  9:00           ` Isaac True
2022-07-08 11:44             ` Guenter Roeck
2022-07-12 21:04               ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220629110626.2158127-2-isaac.true@canonical.com \
    --to=isaac.true@canonical.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=wim@linux-watchdog.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).