Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1652961

[PATCH v6 1/3] watchdog: introduce watchdog_worker_should_ping helper

From Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Newsgroups linux.kernel
Subject [PATCH v6 1/3] watchdog: introduce watchdog_worker_should_ping helper
Date 2017-05-30 11:00 +0200
Message-ID <tMLaq-54b-11@gated-at.bofh.it> (permalink)
References <tJWlH-6KH-3@gated-at.bofh.it> <tMLaq-54b-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


This will be useful when the condition becomes slightly more
complicated in the next patch.

Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Esben Haabendal <esben@haabendal.dk>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 drivers/watchdog/watchdog_dev.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index d5d2bbd..caa4b90 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -192,18 +192,23 @@ static int watchdog_ping(struct watchdog_device *wdd)
 	return __watchdog_ping(wdd);
 }
 
+static bool watchdog_worker_should_ping(struct watchdog_core_data *wd_data)
+{
+	struct watchdog_device *wdd = wd_data->wdd;
+
+	return wdd && (watchdog_active(wdd) || watchdog_hw_running(wdd));
+}
+
 static void watchdog_ping_work(struct work_struct *work)
 {
 	struct watchdog_core_data *wd_data;
-	struct watchdog_device *wdd;
 
 	wd_data = container_of(to_delayed_work(work), struct watchdog_core_data,
 			       work);
 
 	mutex_lock(&wd_data->lock);
-	wdd = wd_data->wdd;
-	if (wdd && (watchdog_active(wdd) || watchdog_hw_running(wdd)))
-		__watchdog_ping(wdd);
+	if (watchdog_worker_should_ping(wd_data))
+		__watchdog_ping(wd_data->wdd);
 	mutex_unlock(&wd_data->lock);
 }
 
-- 
2.7.4

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH v6 1/3] watchdog: introduce watchdog_worker_should_ping helper Rasmus Villemoes <rasmus.villemoes@prevas.dk> - 2017-05-30 11:00 +0200

csiph-web