Skip to content

Commit

Permalink
HID: input: do not report stylus battery state as "full"
Browse files Browse the repository at this point in the history
[ Upstream commit f4abaa9 ]

The power supply states of discharging, charging, full, etc, represent
state of charging, not the capacity level of the battery (for which
we have a separate property). Current HID usage tables to not allow
for expressing charging state of the batteries found in generic
styli, so we should simply assume that the battery is discharging
even if current capacity is at 100% when battery strength reporting
is done via HID interface. In fact, we were doing just that before
commit 581c448.

This change helps UIs to not mis-represent fully charged batteries in
styli as being charging/topping-off.

Fixes: 581c448 ("HID: input: map digitizer battery usage")
Reported-by: Kenneth Albanowski <[email protected]>
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
dtor authored and gregkh committed Sep 22, 2021
1 parent 0656eb5 commit bd74d6d
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions drivers/hid/hid-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,6 @@ static int hidinput_get_battery_property(struct power_supply *psy,

if (dev->battery_status == HID_BATTERY_UNKNOWN)
val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
else if (dev->battery_capacity == 100)
val->intval = POWER_SUPPLY_STATUS_FULL;
else
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
break;
Expand Down

0 comments on commit bd74d6d

Please sign in to comment.