summaryrefslogtreecommitdiff
path: root/drivers/hid
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2025-10-14 21:28:44 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-23 16:24:37 +0200
commit05a4e3337c8922371a4d52c24e46ba7045240f54 (patch)
treea23be00c234f426d8bbddf4761d4758bcdae56ca /drivers/hid
parent46ef903d8c0b99b6738dcb936015584236b94658 (diff)
downloadlinux-05a4e3337c8922371a4d52c24e46ba7045240f54.tar.gz
linux-05a4e3337c8922371a4d52c24e46ba7045240f54.tar.bz2
linux-05a4e3337c8922371a4d52c24e46ba7045240f54.zip
HID: hid-input: only ignore 0 battery events for digitizers
[ Upstream commit 0187c08058da3e7f11b356ac27e0c427d36f33f2 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-input.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index f45f856a127f..2c743e35c1d3 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -622,7 +622,10 @@ static void hidinput_update_battery(struct hid_device *dev, unsigned int usage,
return;
}
- if (value == 0 || value < dev->battery_min || value > dev->battery_max)
+ if ((usage & HID_USAGE_PAGE) == HID_UP_DIGITIZER && value == 0)
+ return;
+
+ if (value < dev->battery_min || value > dev->battery_max)
return;
capacity = hidinput_scale_battery_capacity(dev, value);