From patchwork Wed Jan 25 12:17:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 48142 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp247913wrn; Wed, 25 Jan 2023 04:30:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXsGJHuc6sit491Q835EWgOhS4Q38DY1RcN4Zr6Lnfct4rgYoVbcalVmcozAMUvxomOeR7cL X-Received: by 2002:aa7:865a:0:b0:58d:991d:7632 with SMTP id a26-20020aa7865a000000b0058d991d7632mr31813309pfo.5.1674649853516; Wed, 25 Jan 2023 04:30:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674649853; cv=none; d=google.com; s=arc-20160816; b=Yn7qg63GHOgaPf8gwSk2cNtUtBAUPchgAaEE7NLFACQzrK5gpkovDk9jqOMHeFRrAN RwHq+tBivGl6JJbP6CYaI2GLGmkOrA6+pZuJ5+Nv66OTV6cizYvLRa+XIjCRKZo7tchW TvKlAxF77fdzhQFGuf2qSze9dNPl+MQ8tmEP7j0ZHIfW+DmMRxktgMRk3H9WvVsFOyDL GoaNcIYTZH75YvhRDESpreqcTm1qCgEqkPZyeY0G5lYxnn0007xuzJ31zSB36oTTGLCf 7Y0uphH8ZRvf6OCFqBNrWxhpsv+YebGnWrFoSwGqY/t9YXFLBgY5o2jwqGQEbXqYbKpn BxSQ== 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 :message-id:date:subject:cc:to:from; bh=xC617LeWEC+UufZMfAzJKYrZ2tcDulja2fjlTImm3eM=; b=Vq9NdUikL7VfQbdFVsdOYZa0RjrIPpoOwD9Vp/OfQrhIWySruc7u4g25NyJMuOfkZw CUOhB3GfamE+dWZeNNBuuQvKiUOSAGqmMU3IwE0U6TbInnVZYw/SOdOscXnRkhfvptX+ XRygSqSLx6v3/dEhnwMWyerpkRrE73gGc4k793j25maFNPElGDWLXaM2Lv9asMNU1yWW blriMbyKs8G+xl7tmrzXcKXp4sgxu1uHPhTuRWJVVmOPy6Eu6wg39yJGrwkioymHGgcp d6RBopRyuF5A+KpTEEULvjRVnBdtocDl2sd+1KJrMYgXRujGu0PhTPsNUfgzcuNTaDzc vwZA== 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 n63-20020a622742000000b0058150179c5bsi5223362pfn.26.2023.01.25.04.30.37; Wed, 25 Jan 2023 04:30:53 -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 S235424AbjAYMRa (ORCPT + 99 others); Wed, 25 Jan 2023 07:17:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235102AbjAYMR3 (ORCPT ); Wed, 25 Jan 2023 07:17:29 -0500 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B22EB15549; Wed, 25 Jan 2023 04:17:27 -0800 (PST) Received: (Authenticated sender: hadess@hadess.net) by mail.gandi.net (Postfix) with ESMTPSA id 8AABF20002; Wed, 25 Jan 2023 12:17:24 +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 1/2] HID: logitech-hidpp: Don't restart communication if not necessary Date: Wed, 25 Jan 2023 13:17:22 +0100 Message-Id: <20230125121723.3122-1-hadess@hadess.net> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,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?1752724408700658727?= X-GMAIL-MSGID: =?utf-8?q?1755997645100019145?= 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 | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index abf2c95e4d0b..31d1fc23a435 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -4106,6 +4106,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); @@ -4161,6 +4162,10 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) return ret; } + if (hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT || + hidpp->quirks & HIDPP_QUIRK_UNIFYING) + will_restart = true; + INIT_WORK(&hidpp->work, delayed_work_cb); mutex_init(&hidpp->send_mutex); init_waitqueue_head(&hidpp->wait); @@ -4175,7 +4180,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; @@ -4212,6 +4217,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)) { @@ -4226,19 +4232,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) { From patchwork Wed Jan 25 12:17:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 48143 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp248064wrn; Wed, 25 Jan 2023 04:31:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXtMWTKosz2wwsvWBI259BQrFc0AS645O8Y7S4TsZGETGrV9MUZmnK+BVmEEyrc2wE0TiHQD X-Received: by 2002:a05:6a20:428b:b0:a5:7700:2a4a with SMTP id o11-20020a056a20428b00b000a577002a4amr42087083pzj.51.1674649873302; Wed, 25 Jan 2023 04:31:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674649873; cv=none; d=google.com; s=arc-20160816; b=f5qNmoSBMG8UhuEvcQVxYat0xg1I0JDQq/PRoMX0wzDjUj6k/mjM/SAzr7G0F8hdfD qsIBny+1Tpt1/imbYc5RPi7z3GrY+db1KeodT8Twwt/xgWxg9X+pXGl17Xrb0wM1vvCg rHmfyvWa8xh/XI9Abo8cIabxB6DRCnhs6Rji2oea2R/6F8rmcbJCvy3GJX8kFSzmqbNB 5KOnYB6L8nzaQlzTQQtmI07K+3zpS1IOK/CI43DgEgRYqdrzIuuks+Pumy5BINRtioXt bsVtIm22Do+H+smZR40QMLTikoyNbfGKWsNLGj+wI6BqBHecPkrkhTyEm1Qq3D5J+Sky uwVQ== 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=L7lIy8TjCB8Dtl9Rcyq6j8Ar5qY7yxaSV/EOm9jC3EA=; b=xK6xmd4X9euR1mDTb6eWjjALmPp8OF3GtwsmaxJJ92hEBIwrOG/lmWPbaO6S4pkEmm UTnB8RQI0r+Es9vE1aX1KQGhG8OooLdFd65BguNumYzu4FNNVJ911TIYFN71OI5caZUC bLUjw3WSa3ZL+MXyYfnLZV2xZKifeLhzUqRoRdHh5xwb5Bv/Yofx0gFc8eIPMScjtAXE BzxSOuMubpuO7P8EoGKLWQ6VUMzB2yrgQwMUY56irkKUpA2CPMzn5K2AFZf7UCPB16D7 4B2IgdQTjPTa0pUj2FNUNrH6fvMmcyoDXR0P6+tKtyi0KD0hSTlatZ1KUcSRb8RzaThi pBxw== 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 o10-20020a63920a000000b004d112e91b73si4949129pgd.176.2023.01.25.04.31.00; Wed, 25 Jan 2023 04:31:13 -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 S235458AbjAYMRc (ORCPT + 99 others); Wed, 25 Jan 2023 07:17:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235102AbjAYMRb (ORCPT ); Wed, 25 Jan 2023 07:17:31 -0500 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B87715549; Wed, 25 Jan 2023 04:17:29 -0800 (PST) Received: (Authenticated sender: hadess@hadess.net) by mail.gandi.net (Postfix) with ESMTPSA id BEC9B2000A; Wed, 25 Jan 2023 12:17:26 +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/2] HID: logitech-hidpp: Remove HIDPP_QUIRK_NO_HIDINPUT quirk Date: Wed, 25 Jan 2023 13:17:23 +0100 Message-Id: <20230125121723.3122-2-hadess@hadess.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230125121723.3122-1-hadess@hadess.net> References: <20230125121723.3122-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_H2,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?1755997665182114673?= X-GMAIL-MSGID: =?utf-8?q?1755997665182114673?= HIDPP_QUIRK_NO_HIDINPUT isn't used by any devices but still happens to work as HIDPP_QUIRK_DELAYED_INIT is defined to the same value. Remove HIDPP_QUIRK_NO_HIDINPUT and use HIDPP_QUIRK_DELAYED_INIT everywhere instead. Tested on a T650 which requires that quirk, and a number of unifying and Bluetooth devices that don't. Signed-off-by: Bastien Nocera --- drivers/hid/hid-logitech-hidpp.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 31d1fc23a435..ec388e436b6a 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -71,7 +71,7 @@ MODULE_PARM_DESC(disable_tap_to_click, /* bits 2..20 are reserved for classes */ /* #define HIDPP_QUIRK_CONNECT_EVENTS BIT(21) disabled */ #define HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS BIT(22) -#define HIDPP_QUIRK_NO_HIDINPUT BIT(23) +#define HIDPP_QUIRK_DELAYED_INIT BIT(23) #define HIDPP_QUIRK_FORCE_OUTPUT_REPORTS BIT(24) #define HIDPP_QUIRK_UNIFYING BIT(25) #define HIDPP_QUIRK_HIDPP_WHEELS BIT(26) @@ -87,8 +87,6 @@ MODULE_PARM_DESC(disable_tap_to_click, HIDPP_CAPABILITY_HIDPP20_HI_RES_SCROLL | \ HIDPP_CAPABILITY_HIDPP20_HI_RES_WHEEL) -#define HIDPP_QUIRK_DELAYED_INIT HIDPP_QUIRK_NO_HIDINPUT - #define HIDPP_CAPABILITY_HIDPP10_BATTERY BIT(0) #define HIDPP_CAPABILITY_HIDPP20_BATTERY BIT(1) #define HIDPP_CAPABILITY_BATTERY_MILEAGE BIT(2) @@ -4001,7 +3999,7 @@ static void hidpp_connect_event(struct hidpp_device *hidpp) if (hidpp->capabilities & HIDPP_CAPABILITY_HI_RES_SCROLL) hi_res_scroll_enable(hidpp); - if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) || hidpp->delayed_input) + if (!(hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT) || hidpp->delayed_input) /* if the input nodes are already created, we can stop now */ return; @@ -4238,7 +4236,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) hid_hw_close(hdev); hid_hw_stop(hdev); - if (hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) + if (hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT) connect_mask &= ~HID_CONNECT_HIDINPUT; /* Now export the actual inputs and hidraw nodes to the world */