--- zzzz-none-000/linux-4.9.276/drivers/watchdog/watchdog_core.c 2021-07-20 14:21:16.000000000 +0000 +++ falcon-5530-750/linux-4.9.276/drivers/watchdog/watchdog_core.c 2023-04-05 08:19:02.000000000 +0000 @@ -42,6 +42,7 @@ #include "watchdog_core.h" /* For watchdog_dev_register/... */ static DEFINE_IDA(watchdog_ida); +static struct blocking_notifier_head __maybe_unused watchdog_device_notifier; /* * Deferred Registration infrastructure. @@ -137,6 +138,30 @@ } EXPORT_SYMBOL_GPL(watchdog_init_timeout); +#if IS_ENABLED(CONFIG_AVM_WATCHDOG_SHIM_SUPPORT) +int watchdog_register_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&watchdog_device_notifier, nb); +} +EXPORT_SYMBOL(watchdog_register_notifier); +#endif + +static int watchdog_device_notifier_call_chain(unsigned long val, void *v) +{ + if (!IS_ENABLED(CONFIG_AVM_WATCHDOG_SHIM_SUPPORT)) + return NOTIFY_DONE; + + return blocking_notifier_call_chain(&watchdog_device_notifier, val, v); +} + +static void init_watchdog_device_notifier(void) +{ + if (!IS_ENABLED(CONFIG_AVM_WATCHDOG_SHIM_SUPPORT)) + return; + + BLOCKING_INIT_NOTIFIER_HEAD(&watchdog_device_notifier); +} + static int watchdog_reboot_notifier(struct notifier_block *nb, unsigned long code, void *data) { @@ -266,6 +291,8 @@ wdd->id, ret); } + watchdog_device_notifier_call_chain(WATCHDOG_NOTIFY_ADD_DEVICE, wdd); + return 0; } @@ -299,6 +326,8 @@ if (wdd == NULL) return; + watchdog_device_notifier_call_chain(WATCHDOG_NOTIFY_DEL_DEVICE, wdd); + if (wdd->ops->restart) unregister_restart_handler(&wdd->restart_nb); @@ -390,6 +419,8 @@ if (err < 0) return err; + init_watchdog_device_notifier(); + watchdog_deferred_registration(); return 0; }