Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753440AbbKWDWW (ORCPT ); Sun, 22 Nov 2015 22:22:22 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:52468 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753170AbbKWDVV (ORCPT ); Sun, 22 Nov 2015 22:21:21 -0500 From: Guenter Roeck To: linux-watchdog@vger.kernel.org Cc: Wim Van Sebroeck , linux-kernel@vger.kernel.org, Timo Kokkonen , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-doc@vger.kernel.org, Jonathan Corbet , Guenter Roeck Subject: [PATCH v5 5/8] watchdog: Simplify update_worker Date: Sun, 22 Nov 2015 19:21:02 -0800 Message-Id: <1448248865-21684-6-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1448248865-21684-1-git-send-email-linux@roeck-us.net> References: <1448248865-21684-1-git-send-email-linux@roeck-us.net> X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2461 Lines: 85 Drop 'cancel' parameter; simply cancel worker unconditionally if not needed. Signed-off-by: Guenter Roeck --- v5: Added patch. drivers/watchdog/watchdog_dev.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index 832bd5ac15b5..722ea86fcc7c 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -96,15 +96,14 @@ static long watchdog_next_keepalive(struct watchdog_device *wdd) return min_t(long, last_heartbeat - jiffies, keepalive_interval); } -static inline void watchdog_update_worker(struct watchdog_device *wdd, - bool cancel) +static inline void watchdog_update_worker(struct watchdog_device *wdd) { if (watchdog_need_worker(wdd)) { long t = watchdog_next_keepalive(wdd); if (t > 0) mod_delayed_work(watchdog_wq, &wdd->work, t); - } else if (cancel) { + } else { cancel_delayed_work(&wdd->work); } } @@ -133,7 +132,7 @@ static int _watchdog_ping(struct watchdog_device *wdd) else err = wdd->ops->start(wdd); /* restart watchdog */ - watchdog_update_worker(wdd, false); + watchdog_update_worker(wdd); return err; } @@ -198,7 +197,7 @@ static int watchdog_start(struct watchdog_device *wdd) if (err == 0) { set_bit(WDOG_ACTIVE, &wdd->status); wdd->last_keepalive = jiffies; - watchdog_update_worker(wdd, true); + watchdog_update_worker(wdd); } out_start: @@ -243,7 +242,7 @@ static int watchdog_stop(struct watchdog_device *wdd) if (err == 0) { clear_bit(WDOG_ACTIVE, &wdd->status); - watchdog_update_worker(wdd, true); + watchdog_update_worker(wdd); } out_stop: @@ -311,7 +310,7 @@ static int watchdog_set_timeout(struct watchdog_device *wdd, else wdd->timeout = timeout; - watchdog_update_worker(wdd, true); + watchdog_update_worker(wdd); out_timeout: mutex_unlock(&wdd->lock); @@ -590,7 +589,7 @@ static int watchdog_release(struct inode *inode, struct file *file) } cancel_delayed_work_sync(&wdd->work); - watchdog_update_worker(wdd, false); + watchdog_update_worker(wdd); /* * Allow the owner module to be unloaded again unless the watchdog -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/