Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: bcm47xx_wdt.c: add restart handler support

Just like in case of other watchdog drivers, use the new kernel core
API to provide restart support.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>

authored by

Rafał Miłecki and committed by
Wim Van Sebroeck
1cc7495c ba804a95

+21 -1
+20 -1
drivers/watchdog/bcm47xx_wdt.c
··· 169 169 return NOTIFY_DONE; 170 170 } 171 171 172 + static int bcm47xx_wdt_restart(struct notifier_block *this, unsigned long mode, 173 + void *cmd) 174 + { 175 + struct bcm47xx_wdt *wdt; 176 + 177 + wdt = container_of(this, struct bcm47xx_wdt, restart_handler); 178 + wdt->timer_set(wdt, 1); 179 + 180 + return NOTIFY_DONE; 181 + } 182 + 172 183 static struct watchdog_ops bcm47xx_wdt_soft_ops = { 173 184 .owner = THIS_MODULE, 174 185 .start = bcm47xx_wdt_soft_start, ··· 220 209 if (ret) 221 210 goto err_timer; 222 211 223 - ret = watchdog_register_device(&wdt->wdd); 212 + wdt->restart_handler.notifier_call = &bcm47xx_wdt_restart; 213 + wdt->restart_handler.priority = 64; 214 + ret = register_restart_handler(&wdt->restart_handler); 224 215 if (ret) 225 216 goto err_notifier; 217 + 218 + ret = watchdog_register_device(&wdt->wdd); 219 + if (ret) 220 + goto err_handler; 226 221 227 222 dev_info(&pdev->dev, "BCM47xx Watchdog Timer enabled (%d seconds%s%s)\n", 228 223 timeout, nowayout ? ", nowayout" : "", 229 224 soft ? ", Software Timer" : ""); 230 225 return 0; 231 226 227 + err_handler: 228 + unregister_restart_handler(&wdt->restart_handler); 232 229 err_notifier: 233 230 unregister_reboot_notifier(&wdt->notifier); 234 231 err_timer:
+1
include/linux/bcm47xx_wdt.h
··· 16 16 17 17 struct watchdog_device wdd; 18 18 struct notifier_block notifier; 19 + struct notifier_block restart_handler; 19 20 20 21 struct timer_list soft_timer; 21 22 atomic_t soft_ticks;