summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArkadiusz Miśkiewicz <arekm@maven.pl>2013-03-20 22:35:59 +0100
committerRichard Hughes <richard@hughsie.com>2013-03-21 16:23:46 +0000
commitaf24f55c7925c8ea990cb36078b63c17cd671a95 (patch)
tree7045c4ae990a013e2a15c862cf565b677b26b317
parent972acff14532aa1a495b2ee20f24505cb581291a (diff)
downloadupower-af24f55c7925c8ea990cb36078b63c17cd671a95.tar.gz
Invalid request/response for HIDPP_REFRESH_FLAGS_BATTERY in hid++1
Version 1 hid++ HIDPP_REFRESH_FLAGS_BATTERY packets were incorrect. Response packets were incorrectly thrown away as invalid. These packets have HIDPP_HEADER_REQUEST (and not HIDPP_HEADER_RESPONSE as code expexted). Fix that by allowing both types. Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl> Signed-off-by: Richard Hughes <richard@hughsie.com>
-rw-r--r--src/linux/hidpp-device.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/linux/hidpp-device.c b/src/linux/hidpp-device.c
index 58c6e6d..8e861c5 100644
--- a/src/linux/hidpp-device.c
+++ b/src/linux/hidpp-device.c
@@ -327,7 +327,7 @@ hidpp_device_cmd (HidppDevice *device,
goto out;
}
}
- if (buf[0] != HIDPP_HEADER_RESPONSE ||
+ if ((buf[0] != HIDPP_HEADER_REQUEST && buf[0] != HIDPP_HEADER_RESPONSE) ||
buf[1] != device_idx ||
buf[2] != feature_idx ||
buf[3] != function_idx) {
@@ -662,16 +662,14 @@ hidpp_device_refresh (HidppDevice *device,
/* get battery status */
if ((refresh_flags & HIDPP_REFRESH_FLAGS_BATTERY) > 0) {
if (priv->version == 1) {
- buf[0] = HIDPP_READ_SHORT_REGISTER;
- buf[1] = HIDPP_READ_SHORT_REGISTER_BATTERY;
+ buf[0] = 0x00;
+ buf[1] = 0x00;
buf[2] = 0x00;
- buf[3] = 0x00;
- buf[4] = 0x00;
ret = hidpp_device_cmd (device,
priv->device_idx,
- HIDPP_FEATURE_ROOT_INDEX,
- HIDPP_FEATURE_ROOT_FN_PING,
- buf, 5,
+ HIDPP_READ_SHORT_REGISTER,
+ HIDPP_READ_SHORT_REGISTER_BATTERY,
+ buf, 3,
buf, 1,
error);
if (!ret)