From 6465e29536ed740086d2e3b79106f597c977acbd Mon Sep 17 00:00:00 2001 From: luguohong Date: Fri, 1 Dec 2023 22:42:34 +0800 Subject: [PATCH] BACKPORT: HID: input: map battery system charging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HID descriptors with Battery System (0x85) Charging (0x44) usage are ignored and POWER_SUPPLY_STATUS_DISCHARGING is always reported to user space, even when the device is charging. Map this usage and when it is reported set the right charging status. In addition, add KUnit tests to make sure that the charging status is correctly set and reported. They can be run with the usual command: $ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/hid Signed-off-by: José Expósito Signed-off-by: Jiri Kosina Bug: 305125317 Change-Id: Iad6a8177ad6954ad8ac2b714cc35acffcf2f226f (cherry picked from commit a608dc1c06397dc50ab773498433432fb5938f92) Signed-off-by: luguohong --- drivers/hid/hid-input.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 4900269d2c1a..5a989b55461b 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -636,6 +636,7 @@ static bool hidinput_set_battery_charge_status(struct hid_device *dev, dev->battery_charge_status = value ? POWER_SUPPLY_STATUS_CHARGING : POWER_SUPPLY_STATUS_DISCHARGING; + power_supply_changed(dev->battery); return true; }