summaryrefslogtreecommitdiff
path: root/src/linux/up-device-unifying.c
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-08-19 11:22:00 +0200
committerMartin Pitt <martinpitt@gnome.org>2013-09-03 08:31:27 +0200
commit88398cf75b0f98427aa35cca4c6e0aa43e3e7e1a (patch)
tree11632170e57029d8c10f2797a1ed9178e9da8453 /src/linux/up-device-unifying.c
parentd4d66c205f2291288f8f7539bc5c4da45ea0c4cf (diff)
downloadupower-88398cf75b0f98427aa35cca4c6e0aa43e3e7e1a.tar.gz
hidpp: improve HID++ version detection, fix uninit var
Do not assume HID++ 1.0 when device is unreachable. This allows up_device_unifying_refresh() to be optimized to stop sending a ping message at every refresh for HID++ 1.0 devices. priv->version will now always contain 0 when the real HID++ version of a device is not (yet) known, comments are updated to reflect this. Also fix an uninitialised msg variable that might confuse the error handler in hidpp_device_refresh. Signed-off-by: Peter Wu <lekensteyn@gmail.com>
Diffstat (limited to 'src/linux/up-device-unifying.c')
-rw-r--r--src/linux/up-device-unifying.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/linux/up-device-unifying.c b/src/linux/up-device-unifying.c
index b07d515..005a132 100644
--- a/src/linux/up-device-unifying.c
+++ b/src/linux/up-device-unifying.c
@@ -61,12 +61,12 @@ up_device_unifying_refresh (UpDevice *device)
refresh_flags = HIDPP_REFRESH_FLAGS_BATTERY;
/*
- * Device hid++ v2 when in unreachable mode seems to be able
- * to respond to hid++ v1 queries (but fails to respond to v2
- * queries). When it gets waken up it starts responding
- * to v2 queries, so always try to upgrade protocol to v2
+ * When a device is initially unreachable, the HID++ version cannot be
+ * determined. Therefore try determining the HID++ version, otherwise
+ * battery information cannot be retrieved. Assume that the HID++
+ * version does not change once detected.
*/
- if (hidpp_device_get_version (priv->hidpp_device) < 2)
+ if (hidpp_device_get_version (priv->hidpp_device) == 0)
refresh_flags |= HIDPP_REFRESH_FLAGS_VERSION;
ret = hidpp_device_refresh (priv->hidpp_device,