HID: wacom: Lazy-init batteries
authorJason Gerecke <killertofu@gmail.com>
Thu, 13 Apr 2023 18:17:42 +0000 (11:17 -0700)
committerJiri Kosina <jkosina@suse.cz>
Fri, 14 Apr 2023 14:09:02 +0000 (16:09 +0200)
commit7fc68653fc2e1a3457bb886e10164119ac48734f
treed5b6089c194e5e7b70edea76635d3c9ef7a7b7e4
parent08a46b4190d345544d04ce4fe2e1844b772b8535
HID: wacom: Lazy-init batteries

Rather than creating batteries as part of the initial device probe, let's
make the process lazy. This gives us the opportunity to prevent batteries
from being created in situations where they are unnecessary.

There are two cases in particular where batteries are being unnecessarily
created at initialization. These are AES sensors (for which we don't know
any battery status information until a battery-powered pen actually comes
into prox) peripheral tablets which share HID descriptors between the
wired-only and wireless-capable SKUs of a family of devices.

This patch will delay battery initialization of the former until a pen
actually comes into prox. It will delay battery initialization of the
latter until either a pen comes into prox or a "heartbeat" packet is
processed.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=217062
Link: https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/2354
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Tested-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/wacom_sys.c
drivers/hid/wacom_wac.c