ipq806x: set v4.9 as default
[openwrt/openwrt.git] / target / linux / ipq806x / patches-4.4 / 009-7-watchdog-Drop-pointer-to-watchdog-device-from-struct-watchdog_device.patch
1 From 0254e953537c92df3e7d0176f401a211e944fd61 Mon Sep 17 00:00:00 2001
2 From: Guenter Roeck <linux@roeck-us.net>
3 Date: Sun, 3 Jan 2016 15:11:58 -0800
4 Subject: watchdog: Drop pointer to watchdog device from struct watchdog_device
5
6 The lifetime of the watchdog device pointer is different from the lifetime
7 of its character device. Remove it entirely to avoid race conditions.
8
9 Signed-off-by: Guenter Roeck <linux@roeck-us.net>
10 Signed-off-by: Guenter Roeck <linux@roeck-us.net>
11 Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
12 ---
13 Documentation/watchdog/watchdog-kernel-api.txt | 2 --
14 drivers/watchdog/watchdog_core.c | 8 ++++----
15 drivers/watchdog/watchdog_dev.c | 9 ++++-----
16 include/linux/watchdog.h | 2 --
17 4 files changed, 8 insertions(+), 13 deletions(-)
18
19 --- a/Documentation/watchdog/watchdog-kernel-api.txt
20 +++ b/Documentation/watchdog/watchdog-kernel-api.txt
21 @@ -44,7 +44,6 @@ The watchdog device structure looks like
22
23 struct watchdog_device {
24 int id;
25 - struct device *dev;
26 struct device *parent;
27 const struct watchdog_info *info;
28 const struct watchdog_ops *ops;
29 @@ -65,7 +64,6 @@ It contains following fields:
30 /dev/watchdog0 cdev (dynamic major, minor 0) as well as the old
31 /dev/watchdog miscdev. The id is set automatically when calling
32 watchdog_register_device.
33 -* dev: device under the watchdog class (created by watchdog_register_device).
34 * parent: set this to the parent device (or NULL) before calling
35 watchdog_register_device.
36 * info: a pointer to a watchdog_info structure. This structure gives some
37 --- a/drivers/watchdog/watchdog_core.c
38 +++ b/drivers/watchdog/watchdog_core.c
39 @@ -249,8 +249,8 @@ static int __watchdog_register_device(st
40
41 ret = register_reboot_notifier(&wdd->reboot_nb);
42 if (ret) {
43 - dev_err(wdd->dev, "Cannot register reboot notifier (%d)\n",
44 - ret);
45 + pr_err("watchdog%d: Cannot register reboot notifier (%d)\n",
46 + wdd->id, ret);
47 watchdog_dev_unregister(wdd);
48 ida_simple_remove(&watchdog_ida, wdd->id);
49 return ret;
50 @@ -262,8 +262,8 @@ static int __watchdog_register_device(st
51
52 ret = register_restart_handler(&wdd->restart_nb);
53 if (ret)
54 - dev_warn(wdd->dev, "Cannot register restart handler (%d)\n",
55 - ret);
56 + pr_warn("watchog%d: Cannot register restart handler (%d)\n",
57 + wdd->id, ret);
58 }
59
60 return 0;
61 --- a/drivers/watchdog/watchdog_dev.c
62 +++ b/drivers/watchdog/watchdog_dev.c
63 @@ -143,7 +143,8 @@ static int watchdog_stop(struct watchdog
64 return 0;
65
66 if (test_bit(WDOG_NO_WAY_OUT, &wdd->status)) {
67 - dev_info(wdd->dev, "nowayout prevents watchdog being stopped!\n");
68 + pr_info("watchdog%d: nowayout prevents watchdog being stopped!\n",
69 + wdd->id);
70 return -EBUSY;
71 }
72
73 @@ -604,7 +605,7 @@ static int watchdog_release(struct inode
74
75 /* If the watchdog was not stopped, send a keepalive ping */
76 if (err < 0) {
77 - dev_crit(wdd->dev, "watchdog did not stop!\n");
78 + pr_crit("watchdog%d: watchdog did not stop!\n", wdd->id);
79 watchdog_ping(wdd);
80 }
81
82 @@ -750,7 +751,6 @@ int watchdog_dev_register(struct watchdo
83 watchdog_cdev_unregister(wdd);
84 return PTR_ERR(dev);
85 }
86 - wdd->dev = dev;
87
88 return ret;
89 }
90 @@ -765,8 +765,7 @@ int watchdog_dev_register(struct watchdo
91
92 void watchdog_dev_unregister(struct watchdog_device *wdd)
93 {
94 - device_destroy(&watchdog_class, wdd->dev->devt);
95 - wdd->dev = NULL;
96 + device_destroy(&watchdog_class, wdd->wd_data->cdev.dev);
97 watchdog_cdev_unregister(wdd);
98 }
99
100 --- a/include/linux/watchdog.h
101 +++ b/include/linux/watchdog.h
102 @@ -55,7 +55,6 @@ struct watchdog_ops {
103 /** struct watchdog_device - The structure that defines a watchdog device
104 *
105 * @id: The watchdog's ID. (Allocated by watchdog_register_device)
106 - * @dev: The device for our watchdog
107 * @parent: The parent bus device
108 * @info: Pointer to a watchdog_info structure.
109 * @ops: Pointer to the list of watchdog operations.
110 @@ -82,7 +81,6 @@ struct watchdog_ops {
111 */
112 struct watchdog_device {
113 int id;
114 - struct device *dev;
115 struct device *parent;
116 const struct watchdog_info *info;
117 const struct watchdog_ops *ops;