Removes unnecessary goto statement
fini subdevices before destroying them

Signed-off-by: Emil Velikov <[email protected]>
---
 drivers/gpu/drm/nouveau/nouveau_device.c |   26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_device.c 
b/drivers/gpu/drm/nouveau/nouveau_device.c
index 9cc21d1..38ed71a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_device.c
+++ b/drivers/gpu/drm/nouveau/nouveau_device.c
@@ -55,13 +55,13 @@ nouveau_device_init(struct nouveau_device *ndev)
 
        for (i = 0; i < NVDEV_SUBDEV_NR; i++) {
                ret = nouveau_subdev_init(ndev, i, 0);
-               if (ret)
-                       goto error;
+               if (ret) {
+                       for (--i; i >= 0; i--)
+                               nouveau_subdev_fini(ndev, i, false);
+                       break;
+               }
        }
 
-error:
-       for (--i; ret && i >= 0; i--)
-               nouveau_subdev_fini(ndev, i, false);
        return ret;
 }
 
@@ -72,13 +72,13 @@ nouveau_device_fini(struct nouveau_device *ndev, bool 
suspend)
 
        for (i = NVDEV_SUBDEV_NR - 1; i >= 0; i--) {
                ret = nouveau_subdev_fini(ndev, i, suspend);
-               if (ret)
-                       goto error;
+               if (ret) {
+                       for (--i; i >= 0; i--)
+                               nouveau_subdev_init(ndev, i, 0);
+                       break;
+               }
        }
 
-error:
-       for (--i; ret && i >= 0; i--)
-               nouveau_subdev_init(ndev, i, 0);
        return ret;
 }
 
@@ -96,6 +96,7 @@ nouveau_device_create(struct nouveau_device *ndev)
 {
        int disable = nouveau_noaccel;
        int ret = 0;
+       int i;
 
        /* mask out any engines that are known not to work as they should,
         * these can be overridden by the user
@@ -553,7 +554,10 @@ nouveau_device_create(struct nouveau_device *ndev)
                break;
        }
 
-       if (ret)
+       if (ret) {
+               for (i = NVDEV_SUBDEV_NR - 1; i >= 0; i--)
+                       nouveau_subdev_fini(ndev, i, false);
                nouveau_device_destroy(ndev);
+       }
        return ret;
 }
-- 
1.7.10.2

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

Reply via email to