The commit adding the reboot notifier in the core introduced a new error
path in __watchdog_register_device, making error paths quite redundant.

This commit factorizes all error paths that do some cleanup.

Signed-off-by: Damien Riegel <[email protected]>
---
 drivers/watchdog/watchdog_core.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
index 13a7a58..c246f97 100644
--- a/drivers/watchdog/watchdog_core.c
+++ b/drivers/watchdog/watchdog_core.c
@@ -272,8 +272,7 @@ static int __watchdog_register_device(struct 
watchdog_device *wdd)
 
                ret = __watchdog_create_register(wdd);
                if (ret) {
-                       ida_simple_remove(&watchdog_ida, id);
-                       return ret;
+                       goto remove_ida;
                }
        }
 
@@ -284,9 +283,7 @@ static int __watchdog_register_device(struct 
watchdog_device *wdd)
                if (ret) {
                        dev_err(wdd->dev, "Cannot register reboot notifier 
(%d)\n",
                                ret);
-                       __watchdog_unregister_destroy(wdd);
-                       ida_simple_remove(&watchdog_ida, wdd->id);
-                       return ret;
+                       goto unregister_destroy_device;
                }
        }
 
@@ -300,6 +297,13 @@ static int __watchdog_register_device(struct 
watchdog_device *wdd)
        }
 
        return 0;
+
+unregister_destroy_device:
+       __watchdog_unregister_destroy(wdd);
+remove_ida:
+       ida_simple_remove(&watchdog_ida, wdd->id);
+
+       return ret;
 }
 
 /**
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to