Skip to content

Commit 8f0ffd1

Browse files
dtorgregkh
authored andcommitted
HID: hid-input: only ignore 0 battery events for digitizers
[ Upstream commit 0187c08 ] Commit 581c448 ("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: 581c448 ("HID: input: map digitizer battery usage") Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 8d19a7a commit 8f0ffd1

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/hid/hid-input.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,10 @@ static void hidinput_update_battery(struct hid_device *dev, unsigned int usage,
636636
return;
637637
}
638638

639-
if (value == 0 || value < dev->battery_min || value > dev->battery_max)
639+
if ((usage & HID_USAGE_PAGE) == HID_UP_DIGITIZER && value == 0)
640+
return;
641+
642+
if (value < dev->battery_min || value > dev->battery_max)
640643
return;
641644

642645
capacity = hidinput_scale_battery_capacity(dev, value);

0 commit comments

Comments
 (0)