bcm53xx: backport bcm47xx_wdt changes to 3.18 to use this driver in future
[librecmc/librecmc.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 diff --git a/drivers/watchdog/bcm47xx_wdt.c b/drivers/watchdog/bcm47xx_wdt.c
21 index 9816485..b28a072 100644
22 --- a/drivers/watchdog/bcm47xx_wdt.c
23 +++ b/drivers/watchdog/bcm47xx_wdt.c
24 @@ -169,6 +169,17 @@ static int bcm47xx_wdt_notify_sys(struct notifier_block *this,
25         return NOTIFY_DONE;
26  }
27  
28 +static int bcm47xx_wdt_restart(struct notifier_block *this, unsigned long mode,
29 +                              void *cmd)
30 +{
31 +       struct bcm47xx_wdt *wdt;
32 +
33 +       wdt = container_of(this, struct bcm47xx_wdt, restart_handler);
34 +       wdt->timer_set(wdt, 1);
35 +
36 +       return NOTIFY_DONE;
37 +}
38 +
39  static struct watchdog_ops bcm47xx_wdt_soft_ops = {
40         .owner          = THIS_MODULE,
41         .start          = bcm47xx_wdt_soft_start,
42 @@ -209,15 +220,23 @@ static int bcm47xx_wdt_probe(struct platform_device *pdev)
43         if (ret)
44                 goto err_timer;
45  
46 -       ret = watchdog_register_device(&wdt->wdd);
47 +       wdt->restart_handler.notifier_call = &bcm47xx_wdt_restart;
48 +       wdt->restart_handler.priority = 64;
49 +       ret = register_restart_handler(&wdt->restart_handler);
50         if (ret)
51                 goto err_notifier;
52  
53 +       ret = watchdog_register_device(&wdt->wdd);
54 +       if (ret)
55 +               goto err_handler;
56 +
57         dev_info(&pdev->dev, "BCM47xx Watchdog Timer enabled (%d seconds%s%s)\n",
58                 timeout, nowayout ? ", nowayout" : "",
59                 soft ? ", Software Timer" : "");
60         return 0;
61  
62 +err_handler:
63 +       unregister_restart_handler(&wdt->restart_handler);
64  err_notifier:
65         unregister_reboot_notifier(&wdt->notifier);
66  err_timer:
67 diff --git a/include/linux/bcm47xx_wdt.h b/include/linux/bcm47xx_wdt.h
68 index b708786..5582c21 100644
69 --- a/include/linux/bcm47xx_wdt.h
70 +++ b/include/linux/bcm47xx_wdt.h
71 @@ -16,6 +16,7 @@ struct bcm47xx_wdt {
72  
73         struct watchdog_device wdd;
74         struct notifier_block notifier;
75 +       struct notifier_block restart_handler;
76  
77         struct timer_list soft_timer;
78         atomic_t soft_ticks;
79 -- 
80 1.8.4.5
81