linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] HID: logitech-hidpp: bail out if wtp_connect fails
@ 2014-12-16 22:06 Benjamin Tissoires
  2014-12-16 22:06 ` [PATCH 2/2] HID: logitech-hidpp: store the name of the device in struct hidpp Benjamin Tissoires
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Benjamin Tissoires @ 2014-12-16 22:06 UTC (permalink / raw)
  To: Jiri Kosina, Peter Wu, Nestor Lopez Casado
  Cc: Peter Hutterer, linux-input, linux-kernel

If wtp_connect() fails, that means most of the time that the device has
been disconnected. Subsequent attempts to contact the device will fail
too, so it's simpler to bail out earlier.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
 drivers/hid/hid-logitech-hidpp.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index d008d71..c0fb5fe 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -914,24 +914,24 @@ static int wtp_allocate(struct hid_device *hdev, const struct hid_device_id *id)
 	return 0;
 };
 
-static void wtp_connect(struct hid_device *hdev, bool connected)
+static int wtp_connect(struct hid_device *hdev, bool connected)
 {
 	struct hidpp_device *hidpp = hid_get_drvdata(hdev);
 	struct wtp_data *wd = hidpp->private_data;
 	int ret;
 
 	if (!connected)
-		return;
+		return 0;
 
 	if (!wd->x_size) {
 		ret = wtp_get_config(hidpp);
 		if (ret) {
 			hid_err(hdev, "Can not get wtp config: %d\n", ret);
-			return;
+			return ret;
 		}
 	}
 
-	hidpp_touchpad_set_raw_report_state(hidpp, wd->mt_feature_index,
+	return hidpp_touchpad_set_raw_report_state(hidpp, wd->mt_feature_index,
 			true, true);
 }
 
@@ -1115,8 +1115,11 @@ static void hidpp_connect_event(struct hidpp_device *hidpp)
 	struct input_dev *input;
 	char *name, *devm_name;
 
-	if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)
-		wtp_connect(hdev, connected);
+	if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) {
+		ret = wtp_connect(hdev, connected);
+		if (ret)
+			return;
+	}
 
 	if (!connected || hidpp->delayed_input)
 		return;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-12-17  8:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-16 22:06 [PATCH 1/2] HID: logitech-hidpp: bail out if wtp_connect fails Benjamin Tissoires
2014-12-16 22:06 ` [PATCH 2/2] HID: logitech-hidpp: store the name of the device in struct hidpp Benjamin Tissoires
2014-12-17  1:18   ` Peter Wu
2014-12-17  2:43     ` Benjamin Tissoires
2014-12-16 22:13 ` [PATCH 1/2] HID: logitech-hidpp: bail out if wtp_connect fails Benjamin Tissoires
2014-12-17  1:28   ` Peter Wu
2014-12-17  2:53     ` Benjamin Tissoires
2014-12-16 23:33 ` Peter Wu
2014-12-17  1:32   ` Peter Wu
2014-12-17  4:23     ` Benjamin Tissoires
2014-12-17  8:09 ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).