Merge pull request #580 from wigyori/cc-libpcap
[15.05/openwrt.git] / target / linux / bcm53xx / patches-3.18 / 080-watchdog-bcm47xx_wdt.c-add-restart-handler-support.patch
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
9 Just like in case of other watchdog drivers, use the new kernel core
10 API to provide restart support.
11
12 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
13 Reviewed-by: Guenter Roeck <linux@roeck-us.net>
14 Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
15 ---
16  drivers/watchdog/bcm47xx_wdt.c | 21 ++++++++++++++++++++-
17  include/linux/bcm47xx_wdt.h    |  1 +
18  2 files changed, 21 insertions(+), 1 deletion(-)
19
20 --- a/drivers/watchdog/bcm47xx_wdt.c
21 +++ b/drivers/watchdog/bcm47xx_wdt.c
22 @@ -169,6 +169,17 @@ static int bcm47xx_wdt_notify_sys(struct
23         return NOTIFY_DONE;
24  }
25  
26 +static int bcm47xx_wdt_restart(struct notifier_block *this, unsigned long mode,
27 +                              void *cmd)
28 +{
29 +       struct bcm47xx_wdt *wdt;
30 +
31 +       wdt = container_of(this, struct bcm47xx_wdt, restart_handler);
32 +       wdt->timer_set(wdt, 1);
33 +
34 +       return NOTIFY_DONE;
35 +}
36 +
37  static struct watchdog_ops bcm47xx_wdt_soft_ops = {
38         .owner          = THIS_MODULE,
39         .start          = bcm47xx_wdt_soft_start,
40 @@ -209,15 +220,23 @@ static int bcm47xx_wdt_probe(struct plat
41         if (ret)
42                 goto err_timer;
43  
44 -       ret = watchdog_register_device(&wdt->wdd);
45 +       wdt->restart_handler.notifier_call = &bcm47xx_wdt_restart;
46 +       wdt->restart_handler.priority = 64;
47 +       ret = register_restart_handler(&wdt->restart_handler);
48         if (ret)
49                 goto err_notifier;
50  
51 +       ret = watchdog_register_device(&wdt->wdd);
52 +       if (ret)
53 +               goto err_handler;
54 +
55         dev_info(&pdev->dev, "BCM47xx Watchdog Timer enabled (%d seconds%s%s)\n",
56                 timeout, nowayout ? ", nowayout" : "",
57                 soft ? ", Software Timer" : "");
58         return 0;
59  
60 +err_handler:
61 +       unregister_restart_handler(&wdt->restart_handler);
62  err_notifier:
63         unregister_reboot_notifier(&wdt->notifier);
64  err_timer:
65 --- a/include/linux/bcm47xx_wdt.h
66 +++ b/include/linux/bcm47xx_wdt.h
67 @@ -16,6 +16,7 @@ struct bcm47xx_wdt {
68  
69         struct watchdog_device wdd;
70         struct notifier_block notifier;
71 +       struct notifier_block restart_handler;
72  
73         struct timer_list soft_timer;
74         atomic_t soft_ticks;