input/device: Unregister all UHID event listeners at UHID_DESTROY
authorSonny Sasaka <sonnysasaka@chromium.org>
Fri, 21 Aug 2020 04:35:36 +0000 (21:35 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 12 Apr 2021 09:00:50 +0000 (14:30 +0530)
commitd8bfb40020c3cd6b3e2110e4839b753d79e9441e
treeaf113c4396a8abf2024158877e3df8791452228f
parent1e48abe5ff92c2f3ec960f2430cca8d1ab6298fa
input/device: Unregister all UHID event listeners at UHID_DESTROY

When destroying UHID, we should also unregister all event listeners so
that they don't get double registered at reconnection. It fixes a bug
where battery report is not available to kernel after reconnection and
also prevents memory leak.

Tested with Logitech M535 mouse:
* Connect mouse to the device running BlueZ
* cat /sys/class/power_supply/hid-{addr}-battery/capacity # works
* Disconnect mouse
* Reconnect mouse
* cat /sys/class/power_supply/hid-{addr}-battery/capacity # still works

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
profiles/input/device.c
src/shared/uhid.c
src/shared/uhid.h