080-watchdog-bcm47xx_wdt.c-add-restart-handler-support.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. From 823769d2e6622a48276bee35b2dad5ba77cbdc25 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  3. Date: Sun, 25 Jan 2015 11:40:57 +0100
  4. Subject: [PATCH] watchdog: bcm47xx_wdt.c: add restart handler support
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Just like in case of other watchdog drivers, use the new kernel core
  9. API to provide restart support.
  10. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  11. Reviewed-by: Guenter Roeck <linux@roeck-us.net>
  12. Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
  13. ---
  14. drivers/watchdog/bcm47xx_wdt.c | 21 ++++++++++++++++++++-
  15. include/linux/bcm47xx_wdt.h | 1 +
  16. 2 files changed, 21 insertions(+), 1 deletion(-)
  17. --- a/drivers/watchdog/bcm47xx_wdt.c
  18. +++ b/drivers/watchdog/bcm47xx_wdt.c
  19. @@ -169,6 +169,17 @@ static int bcm47xx_wdt_notify_sys(struct
  20. return NOTIFY_DONE;
  21. }
  22. +static int bcm47xx_wdt_restart(struct notifier_block *this, unsigned long mode,
  23. + void *cmd)
  24. +{
  25. + struct bcm47xx_wdt *wdt;
  26. +
  27. + wdt = container_of(this, struct bcm47xx_wdt, restart_handler);
  28. + wdt->timer_set(wdt, 1);
  29. +
  30. + return NOTIFY_DONE;
  31. +}
  32. +
  33. static struct watchdog_ops bcm47xx_wdt_soft_ops = {
  34. .owner = THIS_MODULE,
  35. .start = bcm47xx_wdt_soft_start,
  36. @@ -209,15 +220,23 @@ static int bcm47xx_wdt_probe(struct plat
  37. if (ret)
  38. goto err_timer;
  39. - ret = watchdog_register_device(&wdt->wdd);
  40. + wdt->restart_handler.notifier_call = &bcm47xx_wdt_restart;
  41. + wdt->restart_handler.priority = 64;
  42. + ret = register_restart_handler(&wdt->restart_handler);
  43. if (ret)
  44. goto err_notifier;
  45. + ret = watchdog_register_device(&wdt->wdd);
  46. + if (ret)
  47. + goto err_handler;
  48. +
  49. dev_info(&pdev->dev, "BCM47xx Watchdog Timer enabled (%d seconds%s%s)\n",
  50. timeout, nowayout ? ", nowayout" : "",
  51. soft ? ", Software Timer" : "");
  52. return 0;
  53. +err_handler:
  54. + unregister_restart_handler(&wdt->restart_handler);
  55. err_notifier:
  56. unregister_reboot_notifier(&wdt->notifier);
  57. err_timer:
  58. --- a/include/linux/bcm47xx_wdt.h
  59. +++ b/include/linux/bcm47xx_wdt.h
  60. @@ -16,6 +16,7 @@ struct bcm47xx_wdt {
  61. struct watchdog_device wdd;
  62. struct notifier_block notifier;
  63. + struct notifier_block restart_handler;
  64. struct timer_list soft_timer;
  65. atomic_t soft_ticks;