HID: logitech-hidpp: 2 fixes in hidpp_root_get_protocol_version()
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>
Mon, 3 Nov 2014 21:09:59 +0000 (16:09 -0500)
committerJiri Kosina <jkosina@suse.cz>
Tue, 4 Nov 2014 10:10:19 +0000 (11:10 +0100)
- remove the constant '1'
- when the device is not connected, the protocol error
  HIDPP_ERROR_RESOURCE_ERROR is raised. We should not warn the user about
  it because it is somewhat expected as an answer when we check if the
  device is connected.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-logitech-hidpp.c

index 61f9e75c45d2075d102363025d49ada250bb0ba0..1a6395d0c2bdb821e6d5bc0253e46547b86f3cb5 100644 (file)
@@ -361,12 +361,16 @@ static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp)
                        CMD_ROOT_GET_PROTOCOL_VERSION,
                        NULL, 0, &response);
 
-       if (ret == 1) {
+       if (ret == HIDPP_ERROR_INVALID_SUBID) {
                hidpp->protocol_major = 1;
                hidpp->protocol_minor = 0;
                return 0;
        }
 
+       /* the device might not be connected */
+       if (ret == HIDPP_ERROR_RESOURCE_ERROR)
+               return -EIO;
+
        if (ret > 0) {
                hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n",
                        __func__, ret);