From 0254e953537c92df3e7d0176f401a211e944fd61 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Sun, 3 Jan 2016 15:11:58 -0800 Subject: watchdog: Drop pointer to watchdog device from struct watchdog_device The lifetime of the watchdog device pointer is different from the lifetime of its character device. Remove it entirely to avoid race conditions. Signed-off-by: Guenter Roeck Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/watchdog_core.c | 8 ++++---- drivers/watchdog/watchdog_dev.c | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'drivers/watchdog') diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c index ec1ab6c1a80b..e600fd93b7de 100644 --- a/drivers/watchdog/watchdog_core.c +++ b/drivers/watchdog/watchdog_core.c @@ -249,8 +249,8 @@ static int __watchdog_register_device(struct watchdog_device *wdd) ret = register_reboot_notifier(&wdd->reboot_nb); if (ret) { - dev_err(wdd->dev, "Cannot register reboot notifier (%d)\n", - ret); + pr_err("watchdog%d: Cannot register reboot notifier (%d)\n", + wdd->id, ret); watchdog_dev_unregister(wdd); ida_simple_remove(&watchdog_ida, wdd->id); return ret; @@ -262,8 +262,8 @@ static int __watchdog_register_device(struct watchdog_device *wdd) ret = register_restart_handler(&wdd->restart_nb); if (ret) - dev_warn(wdd->dev, "Cannot register restart handler (%d)\n", - ret); + pr_warn("watchog%d: Cannot register restart handler (%d)\n", + wdd->id, ret); } return 0; diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index e89ccb2e9603..ba2ecce4aae6 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -143,7 +143,8 @@ static int watchdog_stop(struct watchdog_device *wdd) return 0; if (test_bit(WDOG_NO_WAY_OUT, &wdd->status)) { - dev_info(wdd->dev, "nowayout prevents watchdog being stopped!\n"); + pr_info("watchdog%d: nowayout prevents watchdog being stopped!\n", + wdd->id); return -EBUSY; } @@ -604,7 +605,7 @@ static int watchdog_release(struct inode *inode, struct file *file) /* If the watchdog was not stopped, send a keepalive ping */ if (err < 0) { - dev_crit(wdd->dev, "watchdog did not stop!\n"); + pr_crit("watchdog%d: watchdog did not stop!\n", wdd->id); watchdog_ping(wdd); } @@ -751,7 +752,6 @@ int watchdog_dev_register(struct watchdog_device *wdd) watchdog_cdev_unregister(wdd); return PTR_ERR(dev); } - wdd->dev = dev; return ret; } @@ -766,8 +766,7 @@ int watchdog_dev_register(struct watchdog_device *wdd) void watchdog_dev_unregister(struct watchdog_device *wdd) { - device_destroy(&watchdog_class, wdd->dev->devt); - wdd->dev = NULL; + device_destroy(&watchdog_class, wdd->wd_data->cdev.dev); watchdog_cdev_unregister(wdd); } -- cgit v1.2.3