hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/watchdog/iTCO_wdt.c
....@@ -426,6 +426,20 @@
426426 return time_left;
427427 }
428428
429
+/* Returns true if the watchdog was running */
430
+static bool iTCO_wdt_set_running(struct iTCO_wdt_private *p)
431
+{
432
+ u16 val;
433
+
434
+ /* Bit 11: TCO Timer Halt -> 0 = The TCO timer is enabled */
435
+ val = inw(TCO1_CNT(p));
436
+ if (!(val & BIT(11))) {
437
+ set_bit(WDOG_HW_RUNNING, &p->wddev.status);
438
+ return true;
439
+ }
440
+ return false;
441
+}
442
+
429443 /*
430444 * Kernel Interfaces
431445 */
....@@ -514,9 +528,6 @@
514528 return -ENODEV; /* Cannot reset NO_REBOOT bit */
515529 }
516530
517
- /* Set the NO_REBOOT bit to prevent later reboots, just for sure */
518
- p->update_no_reboot_bit(p->no_reboot_priv, true);
519
-
520531 if (turn_SMI_watchdog_clear_off >= p->iTCO_version) {
521532 /*
522533 * Bit 13: TCO_EN -> 0
....@@ -568,8 +579,13 @@
568579 watchdog_set_drvdata(&p->wddev, p);
569580 platform_set_drvdata(pdev, p);
570581
571
- /* Make sure the watchdog is not running */
572
- iTCO_wdt_stop(&p->wddev);
582
+ if (!iTCO_wdt_set_running(p)) {
583
+ /*
584
+ * If the watchdog was not running set NO_REBOOT now to
585
+ * prevent later reboots.
586
+ */
587
+ p->update_no_reboot_bit(p->no_reboot_priv, true);
588
+ }
573589
574590 /* Check that the heartbeat value is within it's range;
575591 if not reset to the default */