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>
hid = hid_allocate_device();
if (IS_ERR(hid)) {
ret = PTR_ERR(hid);
- goto free_ghid;
+ goto err_free_ghid;
}
connection->private = ghid;
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;