Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

HID: hid-input: only ignore 0 battery events for digitizers

Commit 581c4484769e ("HID: input: map digitizer battery usage") added
handling of battery events for digitizers (typically for batteries
presented in stylii). Digitizers typically report correct battery levels
only when stylus is actively touching the surface, and in other cases
they may report battery level of 0. To avoid confusing consumers of the
battery information the code was added to filer out reports with 0
battery levels.

However there exist other kinds of devices that may legitimately report
0 battery levels. Fix this by filtering out 0-level reports only for
digitizer usages, and continue reporting them for other kinds of devices
(Smart Batteries, etc).

Reported-by: 卢国宏 <luguohong@xiaomi.com>
Fixes: 581c4484769e ("HID: input: map digitizer battery usage")
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>

authored by

Dmitry Torokhov and committed by
Jiri Kosina
0187c080 a7cdc208

+4 -1
+4 -1
drivers/hid/hid-input.c
··· 635 635 return; 636 636 } 637 637 638 - if (value == 0 || value < dev->battery_min || value > dev->battery_max) 638 + if ((usage & HID_USAGE_PAGE) == HID_UP_DIGITIZER && value == 0) 639 + return; 640 + 641 + if (value < dev->battery_min || value > dev->battery_max) 639 642 return; 640 643 641 644 capacity = hidinput_scale_battery_capacity(dev, value);