summaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorJason Gerecke <killertofu@gmail.com>2017-04-28 18:25:31 +0200
committerJiri Kosina <jkosina@suse.cz>2017-05-05 21:46:09 +0200
commitf496c09c0785b60fa6b762ad720ba31f6a9de0ac (patch)
tree6797883f5d56901b50f5f4a9ea723534e3698dd4 /drivers/hid
parentHID: wacom: generic: Scale battery capacity measurements to percentages (diff)
downloadlinux-f496c09c0785b60fa6b762ad720ba31f6a9de0ac.tar.xz
linux-f496c09c0785b60fa6b762ad720ba31f6a9de0ac.zip
HID: wacom: generic: Ignore HID_DG_BATTERYSTRENTH == 0
AES sensors use the value 0 to indicate "not available" rather than "completely dead". Such values are often sent for dozens of reports while the pen is being brought into proximity and can cause userspace to get the wrong impression about the actual battery state. Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com> Reviewed-by: Ping Cheng <ping.cheng@wacom.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/wacom_wac.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index fd989e09ae2d..70a9e47b215a 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -2036,6 +2036,8 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field
wacom_wac->hid_data.sense_state = value;
return;
case HID_DG_BATTERYSTRENGTH:
+ if (value == 0) /* "not available" */
+ break;
value = value * 100 / (field->logical_maximum - field->logical_minimum);
wacom_wac->hid_data.battery_capacity = value;
wacom_wac->hid_data.bat_connected = 1;