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
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.
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>
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(-)
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
23 struct watchdog_device {
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
41 ret = register_reboot_notifier(&wdd->reboot_nb);
43 - dev_err(wdd->dev, "Cannot register reboot notifier (%d)\n",
45 + pr_err("watchdog%d: Cannot register reboot notifier (%d)\n",
47 watchdog_dev_unregister(wdd);
48 ida_simple_remove(&watchdog_ida, wdd->id);
50 @@ -262,8 +262,8 @@ static int __watchdog_register_device(st
52 ret = register_restart_handler(&wdd->restart_nb);
54 - dev_warn(wdd->dev, "Cannot register restart handler (%d)\n",
56 + pr_warn("watchog%d: Cannot register restart handler (%d)\n",
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
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",
73 @@ -604,7 +605,7 @@ static int watchdog_release(struct inode
75 /* If the watchdog was not stopped, send a keepalive ping */
77 - dev_crit(wdd->dev, "watchdog did not stop!\n");
78 + pr_crit("watchdog%d: watchdog did not stop!\n", wdd->id);
82 @@ -750,7 +751,6 @@ int watchdog_dev_register(struct watchdo
83 watchdog_cdev_unregister(wdd);
90 @@ -765,8 +765,7 @@ int watchdog_dev_register(struct watchdo
92 void watchdog_dev_unregister(struct watchdog_device *wdd)
94 - device_destroy(&watchdog_class, wdd->dev->devt);
96 + device_destroy(&watchdog_class, wdd->wd_data->cdev.dev);
97 watchdog_cdev_unregister(wdd);
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
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 {
112 struct watchdog_device {
114 - struct device *dev;
115 struct device *parent;
116 const struct watchdog_info *info;
117 const struct watchdog_ops *ops;