HID: logitech-hidpp: notify battery on connect
authorBenjamin Tissoires <[email protected]>
Mon, 27 Mar 2017 14:59:33 +0000 (16:59 +0200)
committerJiri Kosina <[email protected]>
Thu, 6 Apr 2017 12:36:38 +0000 (14:36 +0200)
When a device reconnects, there is a high chance its power supply has
been changed (for a battery replacement for instance). Just forward
the battery state here.

Signed-off-by: Benjamin Tissoires <[email protected]>
Tested-by: Bastien Nocera <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
drivers/hid/hid-logitech-hidpp.c

index 22129ddac3aeaea8abfe3a34f8f99e2d4559fe98..0781d2bb00d6171b944b261f95d1957b29f377fe 100644 (file)
@@ -2463,6 +2463,13 @@ static void hidpp_connect_event(struct hidpp_device *hidpp)
 
        hidpp_initialize_battery(hidpp);
 
+       /* forward current battery state */
+       if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) {
+               hidpp20_query_battery_info(hidpp);
+               if (hidpp->battery.ps)
+                       power_supply_changed(hidpp->battery.ps);
+       }
+
        if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) || hidpp->delayed_input)
                /* if the input nodes are already created, we can stop now */
                return;