diff mbox series

[v2,3/5] HID: hid-betopff.c: Refactor code to fix error handling (3/3)

Message ID 05803eec-3fa5-61fb-2129-991b15bc8618@hanno.de (mailing list archive)
State New, archived
Headers show
Series HID: hid-betopff.c: Minor code refactoring | expand

Commit Message

Hanno Zulla July 23, 2018, 3:05 p.m. UTC
HID: hid-betopff.c: Refactor code to fix error handling (3/3)

The driver's betopff_probe() calls betopff_init(), but then doesn't
handle the returned errors. This is a minor refactoring to fold both
functions into one and bring back error handling.

Signed-off-by: Hanno Zulla <kontakt@hanno.de>
---
 drivers/hid/hid-betopff.c | 43 +++++++++++++++------------------------
 1 file changed, 16 insertions(+), 27 deletions(-)
diff mbox series

Patch

diff --git a/drivers/hid/hid-betopff.c b/drivers/hid/hid-betopff.c
index 0ba58f748239..e4e9cbe44515 100644
--- a/drivers/hid/hid-betopff.c
+++ b/drivers/hid/hid-betopff.c
@@ -55,7 +55,7 @@  static int hid_betopff_play(struct input_dev *dev, void *data,
 	return 0;
 }
 
-static int betopff_init(struct hid_device *hdev)
+static int betop_probe(struct hid_device *hdev, const struct hid_device_id *id)
 {
 	struct betopff_device *betopff;
 	struct hid_report *report;
@@ -65,6 +65,21 @@  static int betopff_init(struct hid_device *hdev)
 	int error;
 	int i, j;
 
+	if (id->driver_data)
+		hdev->quirks |= HID_QUIRK_MULTI_INPUT;
+
+	error = hid_parse(hdev);
+	if (error) {
+		hid_err(hdev, "parse failed\n");
+		return error;
+	}
+
+	error = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
+	if (error) {
+		hid_err(hdev, "hw start failed\n");
+		return error;
+	}
+
 	report_list = &hdev->report_enum[HID_OUTPUT_REPORT].report_list;
 	if (list_empty(report_list)) {
 		hid_err(hdev, "no output reports found\n");
@@ -115,32 +130,6 @@  static int betopff_init(struct hid_device *hdev)
 	return 0;
 }
 
-static int betop_probe(struct hid_device *hdev, const struct hid_device_id *id)
-{
-	int ret;
-
-	if (id->driver_data)
-		hdev->quirks |= HID_QUIRK_MULTI_INPUT;
-
-	ret = hid_parse(hdev);
-	if (ret) {
-		hid_err(hdev, "parse failed\n");
-		goto err;
-	}
-
-	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
-	if (ret) {
-		hid_err(hdev, "hw start failed\n");
-		goto err;
-	}
-
-	betopff_init(hdev);
-
-	return 0;
-err:
-	return ret;
-}
-
 static const struct hid_device_id betop_devices[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_BETOP_2185BFM, 0x2208) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_BETOP_2185PC, 0x5506) },