linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: minyard@acm.org
To: Guenter Roeck <linux@roeck-us.net>,
	Wim Van Sebroeck <wim@linux-watchdog.org>
Cc: linux-watchdog@vger.kernel.org, Corey Minyard <cminyard@mvista.com>
Subject: [PATCH 05/10] watchdog: Export an interface to start the watchdog
Date: Sat, 20 Jun 2020 12:49:02 -0500	[thread overview]
Message-ID: <20200620174907.20229-6-minyard@acm.org> (raw)
In-Reply-To: <20200620174907.20229-1-minyard@acm.org>

From: Corey Minyard <cminyard@mvista.com>

This way a watchdog driver can start itself.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
 drivers/watchdog/watchdog_dev.c | 30 ++++++++++++++++++++++++++----
 include/linux/watchdog.h        |  3 +++
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 6c423aed3f3c..752358df1606 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -253,7 +253,7 @@ static enum hrtimer_restart watchdog_timer_expired(struct hrtimer *timer)
 }
 
 /*
- *	watchdog_start: wrapper to start the watchdog.
+ *	_watchdog_start: wrapper to start the watchdog.
  *	@wdd: the watchdog device to start
  *
  *	The caller must hold wd_data->lock.
@@ -263,7 +263,7 @@ static enum hrtimer_restart watchdog_timer_expired(struct hrtimer *timer)
  *	failure.
  */
 
-static int watchdog_start(struct watchdog_device *wdd)
+static int _watchdog_start(struct watchdog_device *wdd)
 {
 	struct watchdog_core_data *wd_data = wdd->wd_data;
 	ktime_t started_at;
@@ -289,6 +289,28 @@ static int watchdog_start(struct watchdog_device *wdd)
 	return err;
 }
 
+/*
+ *	watchdog_start: External interface to start the watchdog.
+ *	@wdd: the watchdog device to start
+ *
+ *	Start the watchdog if it is not active and mark it active.
+ *	This function returns zero on success or a negative errno code for
+ *	failure.
+ */
+
+int watchdog_start(struct watchdog_device *wdd)
+{
+	struct watchdog_core_data *wd_data = wdd->wd_data;
+	int err;
+
+	mutex_lock(&wd_data->lock);
+	err = _watchdog_start(wdd);
+	mutex_unlock(&wd_data->lock);
+
+	return err;
+}
+EXPORT_SYMBOL_GPL(watchdog_start);
+
 /*
  *	watchdog_stop: wrapper to stop the watchdog.
  *	@wdd: the watchdog device to stop
@@ -837,7 +859,7 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd,
 				break;
 		}
 		if (val & WDIOS_ENABLECARD)
-			err = watchdog_start(wdd);
+			err = _watchdog_start(wdd);
 		break;
 	case WDIOC_KEEPALIVE:
 		if (!(wdd->info->options & WDIOF_KEEPALIVEPING)) {
@@ -935,7 +957,7 @@ static int watchdog_open(struct inode *inode, struct file *file)
 		goto out_clear;
 	}
 
-	err = watchdog_start(wdd);
+	err = _watchdog_start(wdd);
 	if (err < 0)
 		goto out_mod;
 
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h
index 95396b644a9b..1eefae61215d 100644
--- a/include/linux/watchdog.h
+++ b/include/linux/watchdog.h
@@ -205,6 +205,9 @@ static inline void *watchdog_get_drvdata(struct watchdog_device *wdd)
 int watchdog_set_timeout(struct watchdog_device *wdd, unsigned int timeout);
 int watchdog_set_pretimeout(struct watchdog_device *wdd, unsigned int timeout);
 
+/* Allow the driver to start the watchdog. */
+int watchdog_start(struct watchdog_device *wdd);
+
 /* Use the following functions to report watchdog pretimeout event */
 #if IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_GOV)
 void watchdog_notify_pretimeout(struct watchdog_device *wdd);
-- 
2.17.1


  parent reply	other threads:[~2020-06-20 17:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-20 17:48 [PATCH 00/10] Convert the IPMI watchdog to use the watchdog minyard
2020-06-20 17:48 ` [PATCH 01/10] watchdog: Ignore stop_on_reboot if no stop function minyard
2020-07-19 14:11   ` Guenter Roeck
2020-06-20 17:48 ` [PATCH 02/10] watchdog: Add read capability minyard
2020-06-20 17:49 ` [PATCH 03/10] watchdog: Add documentation for " minyard
2020-07-01  2:49   ` Guenter Roeck
2020-06-20 17:49 ` [PATCH 04/10] watchdog: Add functions to set the timeout and pretimeout minyard
2020-07-01  2:45   ` Guenter Roeck
2020-06-20 17:49 ` minyard [this message]
2020-07-01  2:46   ` [PATCH 05/10] watchdog: Export an interface to start the watchdog Guenter Roeck
2020-06-20 17:49 ` [PATCH 06/10] ipmi:watchdog: Convert over to the watchdog framework minyard
2020-06-20 17:49 ` [PATCH 07/10] ipmi:watchdog: Allow the reboot timeout to be specified minyard
2020-06-20 17:49 ` [PATCH 08/10] watchdog: Add a way to extend the timeout on a reboot minyard
2020-07-19 14:25   ` Guenter Roeck
2020-06-20 17:49 ` [PATCH 09/10] ipmi:watchdog: Convert over to watchdog framework reboot handling minyard
2020-06-20 17:49 ` [PATCH 10/10] ipmi:watchdog: Add the op to get the current timeout minyard

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=20200620174907.20229-6-minyard@acm.org \
    --to=minyard@acm.org \
    --cc=cminyard@mvista.com \
    --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).