From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Jiri Kosina <jikos@kernel.org>, Ping Cheng <pinglinux@gmail.com>,
Jason Gerecke <killertofu@gmail.com>,
Aaron Skomra <skomra@gmail.com>,
Peter Hutterer <peter.hutterer@who-t.net>
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Subject: [PATCH 16/27] HID: wacom: rework fail path in probe() and parse_and_register()
Date: Tue, 5 Jul 2016 16:39:12 +0200 [thread overview]
Message-ID: <1467729563-23318-17-git-send-email-benjamin.tissoires@redhat.com> (raw)
In-Reply-To: <1467729563-23318-1-git-send-email-benjamin.tissoires@redhat.com>
Thanks to devres management, we don't need to remember a lot of failure
path. One or two is enough.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
drivers/hid/wacom_sys.c | 37 ++++++++++++++-----------------------
1 file changed, 14 insertions(+), 23 deletions(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 64acb71..241acee 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -1713,7 +1713,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
error = wacom_allocate_inputs(wacom);
if (error)
- goto fail_open_group;
+ goto fail;
/*
* 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)
} else if ((features->pktlen != WACOM_PKGLEN_BPAD_TOUCH) &&
(features->pktlen != WACOM_PKGLEN_BPAD_TOUCH_USB)) {
error = -ENODEV;
- goto fail_allocate_inputs;
+ goto fail;
}
}
@@ -1746,7 +1746,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
error ? "Ignoring" : "Assuming pen");
if (error)
- goto fail_parsed;
+ goto fail;
features->device_type |= WACOM_DEVICETYPE_PEN;
}
@@ -1757,27 +1757,27 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
error = wacom_add_shared_data(hdev);
if (error)
- goto fail_shared_data;
+ goto fail;
if (!(features->device_type & WACOM_DEVICETYPE_WL_MONITOR) &&
(features->quirks & WACOM_QUIRK_BATTERY)) {
error = wacom_initialize_battery(wacom);
if (error)
- goto fail_battery;
+ goto fail;
}
error = wacom_register_inputs(wacom);
if (error)
- goto fail_register_inputs;
+ goto fail;
if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD) {
error = wacom_initialize_leds(wacom);
if (error)
- goto fail_leds;
+ goto fail;
error = wacom_initialize_remotes(wacom);
if (error)
- goto fail_remote;
+ goto fail;
}
if (features->type == HID_GENERIC)
@@ -1787,7 +1787,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
error = hid_hw_start(hdev, connect_mask);
if (error) {
hid_err(hdev, "hw start failed\n");
- goto fail_hw_start;
+ goto fail;
}
if (!wireless) {
@@ -1826,15 +1826,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
fail_quirks:
hid_hw_stop(hdev);
-fail_hw_start:
-fail_remote:
-fail_leds:
-fail_register_inputs:
-fail_battery:
-fail_shared_data:
-fail_parsed:
-fail_allocate_inputs:
-fail_open_group:
+fail:
wacom_release_resources(wacom);
return error;
}
@@ -2014,7 +2006,7 @@ static int wacom_probe(struct hid_device *hdev,
if (features->check_for_hid_type && features->hid_type != hdev->type) {
error = -ENODEV;
- goto fail_type;
+ goto fail;
}
wacom_wac->hid_data.inputmode = -1;
@@ -2031,12 +2023,12 @@ static int wacom_probe(struct hid_device *hdev,
error = hid_parse(hdev);
if (error) {
hid_err(hdev, "parse failed\n");
- goto fail_parse;
+ goto fail;
}
error = wacom_parse_and_register(wacom, false);
if (error)
- goto fail_parse;
+ goto fail;
if (hdev->bus == BUS_BLUETOOTH) {
error = device_create_file(&hdev->dev, &dev_attr_speed);
@@ -2048,8 +2040,7 @@ static int wacom_probe(struct hid_device *hdev,
return 0;
-fail_parse:
-fail_type:
+fail:
hid_set_drvdata(hdev, NULL);
return error;
}
--
2.5.5
next prev parent reply other threads:[~2016-07-05 14:40 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-05 14:38 [PATCH 00/27] HID: wacom: cleanup/EKR/LED Benjamin Tissoires
2016-07-05 14:38 ` [PATCH 01/27] HID: wacom: actually report the battery level for wireless connected Benjamin Tissoires
2016-07-05 14:38 ` [PATCH 02/27] HID: wacom: store the type in wacom->shared for INTUOSHT and INTUOSHT2 Benjamin Tissoires
2016-07-05 14:38 ` [PATCH 03/27] HID: wacom: remove cleanup of wacom->remote_dir from wacom_clean_inputs() Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 04/27] HID: wacom: untie leds from inputs Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 05/27] HID: wacom: use one work queue per task Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 06/27] HID: wacom: switch battery to devres Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 07/27] HID: wacom: switch inputs " Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 08/27] HID: wacom: put the managed resources in a group Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 09/27] HID: wacom: convert LEDs to devres Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 10/27] HID: wacom: use devm_kasprintf for allocating the name of the remote Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 11/27] HID: wacom: use devres to allocate driver data Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 12/27] HID: wacom: devres manage the shared data too Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 13/27] HID: wacom: leds: dynamically allocate LED groups Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 14/27] HID: wacom: EKR: add a worker to add/remove resources on addition/removal Benjamin Tissoires
2016-07-05 15:21 ` kbuild test robot
2016-07-05 14:39 ` [PATCH 15/27] HID: wacom: EKR: have the wacom resources dynamically allocated Benjamin Tissoires
2016-07-05 14:39 ` Benjamin Tissoires [this message]
2016-07-05 14:39 ` [PATCH 17/27] HID: wacom: EKR: have proper allocator and destructor Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 18/27] HID: wacom: EKR: use devres groups to manage resources Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 19/27] HID: wacom: EKR: have one array of struct remotes instead of many arrays Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 20/27] HID: wacom: EKR: allocate one input node per remote Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 21/27] HID: wacom: EKR: have one power_supply " Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 22/27] HID: wacom: EKR: attach the power_supply on first connection Benjamin Tissoires
[not found] ` <CAEoswT0inHAzo4pP8sBaXpMR_iqUG_U=kdGagAu_m8DybMMDzA@mail.gmail.com>
2016-07-12 9:29 ` Benjamin Tissoires
2016-07-13 15:24 ` Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 23/27] HID: wacom: leds: use the ledclass instead of custom made sysfs files Benjamin Tissoires
2016-07-12 1:42 ` Peter Hutterer
2016-07-05 14:39 ` [PATCH 24/27] HID: wacom: leds: actually release the LEDs on disconnect Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 25/27] HID: wacom: leds: fix ordering of LED banks Benjamin Tissoires
2016-07-12 1:52 ` Peter Hutterer
2016-07-05 14:39 ` [PATCH 26/27] HID: wacom: leds: handle the switch of the LEDs directly in the kernel Benjamin Tissoires
2016-07-05 15:58 ` kbuild test robot
2016-07-05 21:32 ` Benjamin Tissoires
2016-07-05 14:39 ` [PATCH 27/27] HID: wacom: leds: handle Cintiq 24HD leds buttons Benjamin Tissoires
2016-07-05 16:19 ` kbuild test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1467729563-23318-17-git-send-email-benjamin.tissoires@redhat.com \
--to=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=killertofu@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peter.hutterer@who-t.net \
--cc=pinglinux@gmail.com \
--cc=skomra@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®