greybus: hid: clean up init error paths
authorJohan Hovold <johan@hovoldconsulting.com>
Thu, 21 Jan 2016 16:34:22 +0000 (17:34 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Fri, 22 Jan 2016 06:46:38 +0000 (22:46 -0800)
Separate success and error paths more clearly.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/hid.c

index f45b444716ba04bb644b3e20854981ed64423e07..51657b06ea73ca93fc46ee4b428761082ca451a5 100644 (file)
@@ -431,7 +431,7 @@ static int gb_hid_connection_init(struct gb_connection *connection)
        hid = hid_allocate_device();
        if (IS_ERR(hid)) {
                ret = PTR_ERR(hid);
-               goto free_ghid;
+               goto err_free_ghid;
        }
 
        connection->private = ghid;
@@ -440,17 +440,19 @@ static int gb_hid_connection_init(struct gb_connection *connection)
 
        ret = gb_hid_init(ghid);
        if (ret)
-               goto destroy_hid;
+               goto err_destroy_hid;
 
        ret = hid_add_device(hid);
-       if (!ret)
-               return 0;
+       if (ret) {
+               hid_err(hid, "can't add hid device: %d\n", ret);
+               goto err_destroy_hid;
+       }
 
-       hid_err(hid, "can't add hid device: %d\n", ret);
+       return 0;
 
-destroy_hid:
+err_destroy_hid:
        hid_destroy_device(hid);
-free_ghid:
+err_free_ghid:
        kfree(ghid);
 
        return ret;