Commit 3888b0d5 authored by Benjamin Tissoires's avatar Benjamin Tissoires Committed by Jiri Kosina

HID: wacom: rework fail path in probe() and parse_and_register()

Thanks to devres management, we don't need to remember a lot of failure
path. One or two is enough.
Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: default avatarPing Cheng <pingc@wacom.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 83e6b40e
...@@ -1713,7 +1713,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless) ...@@ -1713,7 +1713,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
error = wacom_allocate_inputs(wacom); error = wacom_allocate_inputs(wacom);
if (error) if (error)
goto fail_open_group; goto fail;
/* /*
* Bamboo Pad has a generic hid handling for the Pen, and we switch it * Bamboo Pad has a generic hid handling for the Pen, and we switch it
...@@ -1726,7 +1726,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless) ...@@ -1726,7 +1726,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
} else if ((features->pktlen != WACOM_PKGLEN_BPAD_TOUCH) && } else if ((features->pktlen != WACOM_PKGLEN_BPAD_TOUCH) &&
(features->pktlen != WACOM_PKGLEN_BPAD_TOUCH_USB)) { (features->pktlen != WACOM_PKGLEN_BPAD_TOUCH_USB)) {
error = -ENODEV; error = -ENODEV;
goto fail_allocate_inputs; goto fail;
} }
} }
...@@ -1746,7 +1746,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless) ...@@ -1746,7 +1746,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
error ? "Ignoring" : "Assuming pen"); error ? "Ignoring" : "Assuming pen");
if (error) if (error)
goto fail_parsed; goto fail;
features->device_type |= WACOM_DEVICETYPE_PEN; features->device_type |= WACOM_DEVICETYPE_PEN;
} }
...@@ -1757,27 +1757,27 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless) ...@@ -1757,27 +1757,27 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
error = wacom_add_shared_data(hdev); error = wacom_add_shared_data(hdev);
if (error) if (error)
goto fail_shared_data; goto fail;
if (!(features->device_type & WACOM_DEVICETYPE_WL_MONITOR) && if (!(features->device_type & WACOM_DEVICETYPE_WL_MONITOR) &&
(features->quirks & WACOM_QUIRK_BATTERY)) { (features->quirks & WACOM_QUIRK_BATTERY)) {
error = wacom_initialize_battery(wacom); error = wacom_initialize_battery(wacom);
if (error) if (error)
goto fail_battery; goto fail;
} }
error = wacom_register_inputs(wacom); error = wacom_register_inputs(wacom);
if (error) if (error)
goto fail_register_inputs; goto fail;
if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD) { if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD) {
error = wacom_initialize_leds(wacom); error = wacom_initialize_leds(wacom);
if (error) if (error)
goto fail_leds; goto fail;
error = wacom_initialize_remotes(wacom); error = wacom_initialize_remotes(wacom);
if (error) if (error)
goto fail_remote; goto fail;
} }
if (features->type == HID_GENERIC) if (features->type == HID_GENERIC)
...@@ -1787,7 +1787,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless) ...@@ -1787,7 +1787,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
error = hid_hw_start(hdev, connect_mask); error = hid_hw_start(hdev, connect_mask);
if (error) { if (error) {
hid_err(hdev, "hw start failed\n"); hid_err(hdev, "hw start failed\n");
goto fail_hw_start; goto fail;
} }
if (!wireless) { if (!wireless) {
...@@ -1826,15 +1826,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless) ...@@ -1826,15 +1826,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
fail_quirks: fail_quirks:
hid_hw_stop(hdev); hid_hw_stop(hdev);
fail_hw_start: fail:
fail_remote:
fail_leds:
fail_register_inputs:
fail_battery:
fail_shared_data:
fail_parsed:
fail_allocate_inputs:
fail_open_group:
wacom_release_resources(wacom); wacom_release_resources(wacom);
return error; return error;
} }
...@@ -2014,7 +2006,7 @@ static int wacom_probe(struct hid_device *hdev, ...@@ -2014,7 +2006,7 @@ static int wacom_probe(struct hid_device *hdev,
if (features->check_for_hid_type && features->hid_type != hdev->type) { if (features->check_for_hid_type && features->hid_type != hdev->type) {
error = -ENODEV; error = -ENODEV;
goto fail_type; goto fail;
} }
wacom_wac->hid_data.inputmode = -1; wacom_wac->hid_data.inputmode = -1;
...@@ -2031,12 +2023,12 @@ static int wacom_probe(struct hid_device *hdev, ...@@ -2031,12 +2023,12 @@ static int wacom_probe(struct hid_device *hdev,
error = hid_parse(hdev); error = hid_parse(hdev);
if (error) { if (error) {
hid_err(hdev, "parse failed\n"); hid_err(hdev, "parse failed\n");
goto fail_parse; goto fail;
} }
error = wacom_parse_and_register(wacom, false); error = wacom_parse_and_register(wacom, false);
if (error) if (error)
goto fail_parse; goto fail;
if (hdev->bus == BUS_BLUETOOTH) { if (hdev->bus == BUS_BLUETOOTH) {
error = device_create_file(&hdev->dev, &dev_attr_speed); error = device_create_file(&hdev->dev, &dev_attr_speed);
...@@ -2048,8 +2040,7 @@ static int wacom_probe(struct hid_device *hdev, ...@@ -2048,8 +2040,7 @@ static int wacom_probe(struct hid_device *hdev,
return 0; return 0;
fail_parse: fail:
fail_type:
hid_set_drvdata(hdev, NULL); hid_set_drvdata(hdev, NULL);
return error; return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment