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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
---
 drivers/hid/hid-betopff.c | 43 +++++++++++++++------------------------
 1 file changed, 16 insertions(+), 27 deletions(-)

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) },
-- 
2.17.1


--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux