From patchwork Tue Dec 20 15:43:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 35125 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3036143wrn; Tue, 20 Dec 2022 07:45:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf6SuSJ/f0o1MSCbcqOHAYf4jQf1tle3CvojU5XR0i+3EmPRXAkskEvy8ILz6fEkMU2jhweV X-Received: by 2002:aa7:cb81:0:b0:467:86c7:c4a8 with SMTP id r1-20020aa7cb81000000b0046786c7c4a8mr34984063edt.41.1671551105097; Tue, 20 Dec 2022 07:45:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671551105; cv=none; d=google.com; s=arc-20160816; b=DUC2ticdGMvGdGvXPJ3idq1upk4CxBq/Y/YMwDpPmTJUdiqLnFlnBY/1VPZWYXunmg L4Ohe8Xf+O578hHFI2Ps5Ut7yfQeGRvmAwtWtdkA1uxnuUB2XOgdvLO8GQHAwlqyjzh9 lH007bsYLERTh2otgaBmqufMaqe00mMUQfuOCNf5hlpwuPqtFXZ7BCrhO1lhL4EIbWpZ psu9NZ24GVWf4i6YM1mp4fT2fC9DTlPDJBwzSIs6uKLjpSkBKDC+M5wSVAEiC372ANCW dtJSCHK8nocDnvM+SJmDHCbhtjRxIuEruBlLSk/Ia3GNLt4NXfMMzGhXMEqb9KyWRQ3s QwTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=HEbLfH3P1ULpHtKntFSTcU/e6vIDfCJJGE/urGQesW8=; b=mwiYlM4FaOQRsVGEMUijZRienvmdAHGTlXiUKgz+XcaU3LxrNXAakHZ7A4Xwo/gFeH rRhcppsNV+RE+bLh29HW4L4hcz8UgiB43zqbmRuLjI8bS5/ACwoi3RkSGd+g4hfFRS7Q 8hSpkXj5IH7JwEbFMc5yKOK+VZU3+Z1CNiSLCNXigwkzEwKEZwDqq1jRF1ZLKPzGez02 mpQxeJmjwyuNkZw/CrWHAGqvvNohDWStPk86Z748aPbEVCRdxv8dc2vSe5/JmPdXOdX7 elUP87Zeq9/oJFR6cOZeTxbOWBShDCoCquEVUAFsAGgPYh4FryA0qKoeu+DnFa3FXwVU 3Z9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a056402500400b00461dc830100si11993306eda.452.2022.12.20.07.44.41; Tue, 20 Dec 2022 07:45:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233855AbiLTPoD (ORCPT + 99 others); Tue, 20 Dec 2022 10:44:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229653AbiLTPny (ORCPT ); Tue, 20 Dec 2022 10:43:54 -0500 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9CF714D1E; Tue, 20 Dec 2022 07:43:51 -0800 (PST) Received: (Authenticated sender: hadess@hadess.net) by mail.gandi.net (Postfix) with ESMTPSA id 601FE240009; Tue, 20 Dec 2022 15:43:48 +0000 (UTC) From: Bastien Nocera To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jiri Kosina , Benjamin Tissoires , "Peter F . Patel-Schneider" , =?utf-8?q?Filipe_La?= =?utf-8?q?=C3=ADns?= , Nestor Lopez Casado Subject: [PATCH v2 2/3] HID: logitech-hidpp: Don't restart communication if not necessary Date: Tue, 20 Dec 2022 16:43:44 +0100 Message-Id: <20221220154345.474596-2-hadess@hadess.net> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221220154345.474596-1-hadess@hadess.net> References: <20221220154345.474596-1-hadess@hadess.net> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752748371591707494?= X-GMAIL-MSGID: =?utf-8?q?1752748371591707494?= 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 --- drivers/hid/hid-logitech-hidpp.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 7f9187201913..b4e4a8c79c75 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -4310,6 +4310,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) bool connected; unsigned int connect_mask = HID_CONNECT_DEFAULT; struct hidpp_ff_private_data data; + bool will_restart = false; /* report_fixup needs drvdata to be set before we call hid_parse */ hidpp = devm_kzalloc(&hdev->dev, sizeof(*hidpp), GFP_KERNEL); @@ -4360,6 +4361,9 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) return ret; } + if (hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT) + will_restart = true; + INIT_WORK(&hidpp->work, delayed_work_cb); mutex_init(&hidpp->send_mutex); init_waitqueue_head(&hidpp->wait); @@ -4374,7 +4378,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 * 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) { hid_err(hdev, "hw start failed\n"); goto hid_hw_start_fail; @@ -4411,6 +4415,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) hidpp->wireless_feature_index = 0; else if (ret) goto hid_hw_init_fail; + ret = 0; } if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { @@ -4425,19 +4430,21 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) hidpp_connect_event(hidpp); - /* Reset the HID node state */ - hid_device_io_stop(hdev); - hid_hw_close(hdev); - hid_hw_stop(hdev); + if (will_restart) { + /* Reset the HID node state */ + hid_device_io_stop(hdev); + hid_hw_close(hdev); + hid_hw_stop(hdev); - if (hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) - connect_mask &= ~HID_CONNECT_HIDINPUT; + if (hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) + connect_mask &= ~HID_CONNECT_HIDINPUT; - /* Now export the actual inputs and hidraw nodes to the world */ - ret = hid_hw_start(hdev, connect_mask); - if (ret) { - hid_err(hdev, "%s:hid_hw_start returned error\n", __func__); - goto hid_hw_start_fail; + /* Now export the actual inputs and hidraw nodes to the world */ + ret = hid_hw_start(hdev, connect_mask); + if (ret) { + hid_err(hdev, "%s:hid_hw_start returned error\n", __func__); + goto hid_hw_start_fail; + } } if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) {