mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-08 14:13:53 +00:00
HID: logitech-hidpp: Don't restart communication if not necessary
Don't stop and restart communication with the device unless we need to modify the connect flags used because of a device quirk. Signed-off-by: Bastien Nocera <hadess@hadess.net> Link: https://lore.kernel.org/r/20230125121723.3122-1-hadess@hadess.net Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
This commit is contained in:
parent
43551d9bea
commit
498ba20690
@ -4106,6 +4106,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
|||||||
bool connected;
|
bool connected;
|
||||||
unsigned int connect_mask = HID_CONNECT_DEFAULT;
|
unsigned int connect_mask = HID_CONNECT_DEFAULT;
|
||||||
struct hidpp_ff_private_data data;
|
struct hidpp_ff_private_data data;
|
||||||
|
bool will_restart = false;
|
||||||
|
|
||||||
/* report_fixup needs drvdata to be set before we call hid_parse */
|
/* report_fixup needs drvdata to be set before we call hid_parse */
|
||||||
hidpp = devm_kzalloc(&hdev->dev, sizeof(*hidpp), GFP_KERNEL);
|
hidpp = devm_kzalloc(&hdev->dev, sizeof(*hidpp), GFP_KERNEL);
|
||||||
@ -4156,6 +4157,10 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT ||
|
||||||
|
hidpp->quirks & HIDPP_QUIRK_UNIFYING)
|
||||||
|
will_restart = true;
|
||||||
|
|
||||||
INIT_WORK(&hidpp->work, delayed_work_cb);
|
INIT_WORK(&hidpp->work, delayed_work_cb);
|
||||||
mutex_init(&hidpp->send_mutex);
|
mutex_init(&hidpp->send_mutex);
|
||||||
init_waitqueue_head(&hidpp->wait);
|
init_waitqueue_head(&hidpp->wait);
|
||||||
@ -4170,7 +4175,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
|||||||
* Plain USB connections need to actually call start and open
|
* Plain USB connections need to actually call start and open
|
||||||
* on the transport driver to allow incoming data.
|
* on the transport driver to allow incoming data.
|
||||||
*/
|
*/
|
||||||
ret = hid_hw_start(hdev, 0);
|
ret = hid_hw_start(hdev, will_restart ? 0 : connect_mask);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
hid_err(hdev, "hw start failed\n");
|
hid_err(hdev, "hw start failed\n");
|
||||||
goto hid_hw_start_fail;
|
goto hid_hw_start_fail;
|
||||||
@ -4207,6 +4212,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
|||||||
hidpp->wireless_feature_index = 0;
|
hidpp->wireless_feature_index = 0;
|
||||||
else if (ret)
|
else if (ret)
|
||||||
goto hid_hw_init_fail;
|
goto hid_hw_init_fail;
|
||||||
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) {
|
if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) {
|
||||||
@ -4221,19 +4227,21 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
|||||||
|
|
||||||
hidpp_connect_event(hidpp);
|
hidpp_connect_event(hidpp);
|
||||||
|
|
||||||
/* Reset the HID node state */
|
if (will_restart) {
|
||||||
hid_device_io_stop(hdev);
|
/* Reset the HID node state */
|
||||||
hid_hw_close(hdev);
|
hid_device_io_stop(hdev);
|
||||||
hid_hw_stop(hdev);
|
hid_hw_close(hdev);
|
||||||
|
hid_hw_stop(hdev);
|
||||||
|
|
||||||
if (hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT)
|
if (hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT)
|
||||||
connect_mask &= ~HID_CONNECT_HIDINPUT;
|
connect_mask &= ~HID_CONNECT_HIDINPUT;
|
||||||
|
|
||||||
/* Now export the actual inputs and hidraw nodes to the world */
|
/* Now export the actual inputs and hidraw nodes to the world */
|
||||||
ret = hid_hw_start(hdev, connect_mask);
|
ret = hid_hw_start(hdev, connect_mask);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
hid_err(hdev, "%s:hid_hw_start returned error\n", __func__);
|
hid_err(hdev, "%s:hid_hw_start returned error\n", __func__);
|
||||||
goto hid_hw_start_fail;
|
goto hid_hw_start_fail;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) {
|
if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) {
|
||||||
|
Loading…
Reference in New Issue
Block a user