public inbox for linux-watchdog@vger.kernel.org
 help / color / mirror / Atom feed
From: aviv.daum@gmail.com
To: wim@linux-watchdog.org, linux@roeck-us.net
Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org,
	avivdaum <aviv.daum@gmail.com>
Subject: [PATCH] watchdog: mtx-1_wdt: synchronize timer teardown in remove
Date: Thu, 12 Mar 2026 23:06:45 +0200	[thread overview]
Message-ID: <20260312210645.10613-1-aviv.daum@gmail.com> (raw)

From: avivdaum <aviv.daum@gmail.com>

Replace the ad-hoc completion based teardown path with a proper
timer synchronization call in remove.

Stop the watchdog and delete the timer synchronously using
timer_delete_sync(), then deregister the misc device.

This removes the open FIXME about locking/testing of queue teardown
and makes the driver follow the current timer API pattern used in
watchdog drivers.

Compile-tested: ARCH=mips CROSS_COMPILE=mips-linux-gnu-
  32r2el_defconfig (drivers/watchdog/mtx-1_wdt.o, W=1/W=2)
Compile-tested: ARCH=mips CROSS_COMPILE=mips-linux-gnu-
  mtx1_defconfig (drivers/watchdog/mtx-1_wdt.o, W=1/W=2)
Compile-tested: ARCH=mips CROSS_COMPILE=mips-linux-gnu-
  malta_defconfig + WATCHDOG=y + COMPILE_TEST=y + WDT_MTX1=m
  (drivers/watchdog/mtx-1_wdt.o, W=1/W=2)
Signed-off-by: avivdaum <aviv.daum@gmail.com>
---
 drivers/watchdog/mtx-1_wdt.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/watchdog/mtx-1_wdt.c b/drivers/watchdog/mtx-1_wdt.c
index f75426cfa..85fe006de 100644
--- a/drivers/watchdog/mtx-1_wdt.c
+++ b/drivers/watchdog/mtx-1_wdt.c
@@ -33,7 +33,6 @@
 #include <linux/fs.h>
 #include <linux/ioport.h>
 #include <linux/timer.h>
-#include <linux/completion.h>
 #include <linux/jiffies.h>
 #include <linux/watchdog.h>
 #include <linux/platform_device.h>
@@ -46,7 +45,6 @@
 static int ticks = 100 * HZ;
 
 static struct {
-	struct completion stop;
 	spinlock_t lock;
 	int running;
 	struct timer_list timer;
@@ -69,8 +67,6 @@ static void mtx1_wdt_trigger(struct timer_list *unused)
 
 	if (mtx1_wdt_device.queue && ticks)
 		mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL);
-	else
-		complete(&mtx1_wdt_device.stop);
 	spin_unlock(&mtx1_wdt_device.lock);
 }
 
@@ -204,7 +200,6 @@ static int mtx1_wdt_probe(struct platform_device *pdev)
 	}
 
 	spin_lock_init(&mtx1_wdt_device.lock);
-	init_completion(&mtx1_wdt_device.stop);
 	mtx1_wdt_device.queue = 0;
 	clear_bit(0, &mtx1_wdt_device.inuse);
 	timer_setup(&mtx1_wdt_device.timer, mtx1_wdt_trigger, 0);
@@ -222,11 +217,8 @@ static int mtx1_wdt_probe(struct platform_device *pdev)
 
 static void mtx1_wdt_remove(struct platform_device *pdev)
 {
-	/* FIXME: do we need to lock this test ? */
-	if (mtx1_wdt_device.queue) {
-		mtx1_wdt_device.queue = 0;
-		wait_for_completion(&mtx1_wdt_device.stop);
-	}
+	mtx1_wdt_stop();
+	timer_delete_sync(&mtx1_wdt_device.timer);
 
 	misc_deregister(&mtx1_wdt_misc);
 }
-- 
2.34.1


             reply	other threads:[~2026-03-12 21:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12 21:06 aviv.daum [this message]
2026-03-12 22:02 ` [PATCH] watchdog: mtx-1_wdt: synchronize timer teardown in remove Guenter Roeck

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=20260312210645.10613-1-aviv.daum@gmail.com \
    --to=aviv.daum@gmail.com \
    --cc=linux-kernel@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