This patch makes WirelessDeviceStatus (0x1d4b) events get detected as connection events on devices with HIDPP_QUIRK_WIRELESS_DEVICE_STATUS. This quirk is currently an alias for HIDPP_QUIRK_CLASS_BLUETOOTH since the added Bluetooth devices do not support regular connect events. Signed-off-by: Mazin Rezk <mnrzk@xxxxxxxxxxxxxx> --- drivers/hid/hid-logitech-hidpp.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 64ac94c581aa..4a6e41c2c9fc 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -84,6 +84,7 @@ MODULE_PARM_DESC(disable_tap_to_click, /* Just an alias for now, may possibly be a catch-all in the future */ #define HIDPP_QUIRK_MISSING_SHORT_REPORTS HIDPP_QUIRK_CLASS_BLUETOOTH +#define HIDPP_QUIRK_WIRELESS_DEVICE_STATUS HIDPP_QUIRK_CLASS_BLUETOOTH #define HIDPP_QUIRK_DELAYED_INIT HIDPP_QUIRK_NO_HIDINPUT @@ -406,9 +407,22 @@ static inline bool hidpp_match_error(struct hidpp_report *question, (answer->fap.params[0] == question->fap.funcindex_clientid); } -static inline bool hidpp_report_is_connect_event(struct hidpp_report *report) +#define HIDPP_PAGE_WIRELESS_DEVICE_STATUS 0x1d4b + +static inline bool hidpp_report_is_connect_event(struct hidpp_device *hidpp, + struct hidpp_report *report) { - return (report->report_id == REPORT_ID_HIDPP_SHORT) && + if (hidpp->quirks & HIDPP_QUIRK_WIRELESS_DEVICE_STATUS) { + /* If feature is invalid, skip array check */ + if (report->fap.feature_index > hidpp->feature_count) + return false; + + return (hidpp->features[report->fap.feature_index] == + HIDPP_PAGE_WIRELESS_DEVICE_STATUS); + } + + return ((report->report_id == REPORT_ID_HIDPP_SHORT) || + (hidpp->quirks & HIDPP_QUIRK_MISSING_SHORT_REPORTS)) && (report->rap.sub_id == 0x41); } @@ -3159,7 +3173,7 @@ static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data, } } - if (unlikely(hidpp_report_is_connect_event(report))) { + if (unlikely(hidpp_report_is_connect_event(hidpp, report))) { atomic_set(&hidpp->connected, !(report->rap.params[0] & (1 << 6))); if (schedule_work(&hidpp->work) == 0) -- 2.23.0