HID: logitech-hidpp: simplify printing of HID++ version
authorHans de Goede <hdegoede@redhat.com>
Fri, 22 Mar 2019 07:41:38 +0000 (08:41 +0100)
committerJiri Kosina <jkosina@suse.cz>
Mon, 1 Apr 2019 13:14:53 +0000 (15:14 +0200)
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>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-logitech-hidpp.c

index 15ed6177a7a364d6b2634babe0df1be83b4cec7b..3795ae90207ae458678d1a9d4c22b659048f98cd 100644 (file)
@@ -847,7 +847,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 */
@@ -865,18 +865,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;
 }
 
 /* -------------------------------------------------------------------------- */
@@ -3133,8 +3130,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) {
@@ -3291,9 +3286,6 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
                        goto hid_hw_open_failed;
                }
 
-               hid_info(hdev, "HID++ %u.%u device connected.\n",
-                        hidpp->protocol_major, hidpp->protocol_minor);
-
                hidpp_overwrite_name(hdev);
        }