linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] watchdog: core: call device_destroy before watchdog_dev_unregister
@ 2015-11-24 23:45 Damien Riegel
  2015-11-24 23:45 ` [PATCH v2 2/2] watchdog: core: factorize register error paths Damien Riegel
  2015-11-25  2:20 ` [PATCH v2 1/2] watchdog: core: call device_destroy before watchdog_dev_unregister Guenter Roeck
  0 siblings, 2 replies; 7+ messages in thread
From: Damien Riegel @ 2015-11-24 23:45 UTC (permalink / raw)
  To: linux-watchdog; +Cc: Wim Van Sebroeck, Guenter Roeck, kernel, Damien Riegel

device_create is called after watchdog_dev_register, so it makes more
sense to call the cleanup functions in reverse order, ie. device_destroy
before watchdog_dev_unregister.

Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
---
 drivers/watchdog/watchdog_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
index 551af04..e70b6e8 100644
--- a/drivers/watchdog/watchdog_core.c
+++ b/drivers/watchdog/watchdog_core.c
@@ -264,8 +264,8 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
 		if (ret) {
 			dev_err(wdd->dev, "Cannot register reboot notifier (%d)\n",
 				ret);
-			watchdog_dev_unregister(wdd);
 			device_destroy(watchdog_class, devno);
+			watchdog_dev_unregister(wdd);
 			ida_simple_remove(&watchdog_ida, wdd->id);
 			wdd->dev = NULL;
 			return ret;
@@ -324,10 +324,10 @@ static void __watchdog_unregister_device(struct watchdog_device *wdd)
 		unregister_reboot_notifier(&wdd->reboot_nb);
 
 	devno = wdd->cdev.dev;
+	device_destroy(watchdog_class, devno);
 	ret = watchdog_dev_unregister(wdd);
 	if (ret)
 		pr_err("error unregistering /dev/watchdog (err=%d)\n", ret);
-	device_destroy(watchdog_class, devno);
 	ida_simple_remove(&watchdog_ida, wdd->id);
 	wdd->dev = NULL;
 }
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-11-25 22:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-24 23:45 [PATCH v2 1/2] watchdog: core: call device_destroy before watchdog_dev_unregister Damien Riegel
2015-11-24 23:45 ` [PATCH v2 2/2] watchdog: core: factorize register error paths Damien Riegel
2015-11-25  2:20   ` Guenter Roeck
2015-11-25  2:20 ` [PATCH v2 1/2] watchdog: core: call device_destroy before watchdog_dev_unregister Guenter Roeck
2015-11-25 17:09   ` Damien Riegel
2015-11-25 17:57     ` Guenter Roeck
2015-11-25 22:43       ` Damien Riegel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).