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 <benjamin.tissoires@xxxxxxxxxx> --- drivers/hid/hid-logitech-hidpp.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 1fd95c2..3ae2f41 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -2557,9 +2557,6 @@ static int hidpp_initialize_battery(struct hidpp_device *hidpp) return ret; hidpp->quirks |= HIDPP_QUIRK_HIDPP20_BATTERY; } else { - ret = hidpp10_enable_battery_reporting(hidpp); - if (ret) - return -ENOENT; ret = hidpp10_query_battery_status(hidpp); if (ret) { ret = hidpp10_query_battery_mileage(hidpp); @@ -2693,6 +2690,17 @@ static void hidpp_connect_event(struct hidpp_device *hidpp) hidpp_initialize_battery(hidpp); + /* forward current battery state */ + if (hidpp->quirks & HIDPP_QUIRK_HIDPP10_BATTERY) { + hidpp10_enable_battery_reporting(hidpp); + hidpp10_query_battery_status(hidpp); + hidpp10_query_battery_mileage(hidpp); + } else if (hidpp->quirks & HIDPP_QUIRK_HIDPP20_BATTERY) { + hidpp20_query_battery_info(hidpp); + } + if (hidpp->battery.ps) + power_supply_changed(hidpp->battery.ps); + if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT)) /* if HID created the input nodes for us, we can stop now */ return; -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html