Skip to contentSkip to conversation

HID: Print specific timeout error in probe

PATCH In review Andreas Bergmeier 2 participants 2 messages Nov 10, 2022 – Nov 14, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: Print specific timeout error in probe

When -ETIMEOUT gets reported ensure that the error message mentiones timeout.

---
 drivers/hid/hid-logitech-hidpp.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/hid/hid-logitech-hidpp.c +6 -2
index 20ae7f73ef08..a0c148a8df6c 100644
@@ -4438,12 +4438,16 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	if (hidpp->quirks & HIDPP_QUIRK_UNIFYING)
 		hidpp_unifying_init(hidpp);
 
-	connected = hidpp_root_get_protocol_version(hidpp) == 0;
+	ret = hidpp_root_get_protocol_version(hidpp);
+	connected = ret == 0;
 	atomic_set(&hidpp->connected, connected);
 	if (!(hidpp->quirks & HIDPP_QUIRK_UNIFYING)) {
 		if (!connected) {
+			if (ret == -ETIMEDOUT)
+				hid_err(hdev, "Device connection timed out");
+			else
+				hid_err(hdev, "Device not connected");
 			ret = -ENODEV;
-			hid_err(hdev, "Device not connected");
 			goto hid_hw_init_fail;
 		}
 

--
2.34.1

maintainer
#1 lore raw
Quoted 18 lines · Andreas Bergmeier

When -ETIMEOUT gets reported ensure that the error message mentiones timeout.

---
 drivers/hid/hid-logitech-hidpp.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/hid/hid-logitech-hidpp.c +1 -1
index 20ae7f73ef08..a0c148a8df6c 100644
@@ -4438,12 +4438,16 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	if (hidpp->quirks & HIDPP_QUIRK_UNIFYING)
 		hidpp_unifying_init(hidpp);
 
-	connected = hidpp_root_get_protocol_version(hidpp) == 0;
+	ret = hidpp_root_get_protocol_version(hidpp);

drivers/hid/hid-logitech-hidpp.c static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) · line 4446

Quoted 10 lines
drivers/hid/hid-logitech-hidpp.c +5 -1
+	connected = ret == 0;
 	atomic_set(&hidpp->connected, connected);
 	if (!(hidpp->quirks & HIDPP_QUIRK_UNIFYING)) {
 		if (!connected) {
+			if (ret == -ETIMEDOUT)
+				hid_err(hdev, "Device connection timed out");
+			else
+				hid_err(hdev, "Device not connected");
 			ret = -ENODEV;
-			hid_err(hdev, "Device not connected");

Printing as specific error as possible makes sense to me.

I am however wondering whether the better aproach (covering all the cases, not just ETIMEDOUT specifically) wouldn't be to convert all the dbg_hid() in hidpp_send_message_sync() to be proper error messages instead? That would cover also your case, as ETIMEDOUT is handled there as well with debugging message.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs