diff mbox series

[v2,1/3] HID: logitech-hidpp: simplify printing of HID++ version

Message ID 20190322074140.4129-1-hdegoede@redhat.com (mailing list archive)
State Mainlined
Delegated to: Jiri Kosina
Headers show
Series [v2,1/3] HID: logitech-hidpp: simplify printing of HID++ version | expand

Commit Message

Hans de Goede March 22, 2019, 7:41 a.m. UTC
Simply always print the HID++ version on hidpp_root_get_protocol_version
success.

This also fixes the version not being printed when a HID++ device
connected through a receiver is already connected when the hidpp driver
is loaded.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/hid/hid-logitech-hidpp.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

Comments

Jiri Kosina April 1, 2019, 1:15 p.m. UTC | #1
I've now queued this in for-5.2/logitech.

Thanks,
diff mbox series

Patch

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index f4929f1dadf1..004f56e7d66f 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -897,7 +897,7 @@  static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp)
 	if (ret == HIDPP_ERROR_INVALID_SUBID) {
 		hidpp->protocol_major = 1;
 		hidpp->protocol_minor = 0;
-		return 0;
+		goto print_version;
 	}
 
 	/* the device might not be connected */
@@ -915,18 +915,15 @@  static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp)
 	hidpp->protocol_major = response.fap.params[0];
 	hidpp->protocol_minor = response.fap.params[1];
 
-	return ret;
+print_version:
+	hid_info(hidpp->hid_dev, "HID++ %u.%u device connected.\n",
+		 hidpp->protocol_major, hidpp->protocol_minor);
+	return 0;
 }
 
 static bool hidpp_is_connected(struct hidpp_device *hidpp)
 {
-	int ret;
-
-	ret = hidpp_root_get_protocol_version(hidpp);
-	if (!ret)
-		hid_dbg(hidpp->hid_dev, "HID++ %u.%u device connected.\n",
-			hidpp->protocol_major, hidpp->protocol_minor);
-	return ret == 0;
+	return hidpp_root_get_protocol_version(hidpp) == 0;
 }
 
 /* -------------------------------------------------------------------------- */
@@ -3200,8 +3197,6 @@  static void hidpp_connect_event(struct hidpp_device *hidpp)
 			hid_err(hdev, "Can not get the protocol version.\n");
 			return;
 		}
-		hid_info(hdev, "HID++ %u.%u device connected.\n",
-			 hidpp->protocol_major, hidpp->protocol_minor);
 	}
 
 	if (hidpp->name == hdev->name && hidpp->protocol_major >= 2) {
@@ -3409,9 +3404,6 @@  static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
 			goto hid_hw_init_fail;
 		}
 
-		hid_info(hdev, "HID++ %u.%u device connected.\n",
-			 hidpp->protocol_major, hidpp->protocol_minor);
-
 		hidpp_overwrite_name(hdev);
 	}