From patchwork Thu Sep 21 09:21:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kepplinger X-Patchwork-Id: 142887 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5121182vqi; Thu, 21 Sep 2023 13:32:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG049565lytlfpJQ3ifuvl8IuWQA5tk145EH8z+x/Dc7NgpoZfvIzQBHMXU1bEsU+uGuAcn X-Received: by 2002:a17:90a:d3c9:b0:273:ed60:ad52 with SMTP id d9-20020a17090ad3c900b00273ed60ad52mr6394503pjw.37.1695328327919; Thu, 21 Sep 2023 13:32:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695328327; cv=none; d=google.com; s=arc-20160816; b=nAQQv45TW5Htp07td9WggQwBZYrShfZ4WHWcXS7kDa5gB6+d/FlM5jLGqoaAt563JZ 6oAGpWf+ziFPVTUsXjYXcN7p8DTsiTrVJez3KMgh+IZyV6bmX7rW4Hk63zBcinX7sCbB ruh5CqgxYP413nKC2OfsqsNlsdl6JSCVLH8mtC0Y+BQgkELexDujrsL0T8VUJoI6eDoY vgP/zhakfwdquSMF1j71pxxbfEzCq/JPtULkGX20mWuwxwbLxS9Qpzhv6KTdE7uMmgCZ 8iY1FeLPUcbEefTVCpkHtWsBrCOyyhR1kDvVnP/t6UeES8M/IG7+i+Jrhi+tedvxfemI cC1Q== 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:dkim-signature; bh=6+D1LdATPdfFDeNVwYQdBcc4vhU2RAGKsUsmGnVlgFw=; fh=Y8NTCuHDNQUi1Y7edzN1WOu8jwcMKdKWGbAHrwF7W6M=; b=n19HbLkGrYfxLpEQzJYot6LpuCY1IyJ2IKrRF9OmGZPu0+jXwGCYt63oYtD1K21UfB 6Luk6jzeFXr3ee8ZA8QvAH4syLVPfap3/OQbuVrW/+oB2fEQOF3067a2z4mmgntiB2bM rmqrf8zAyF6Em3e0DeGL+xgmhJ3a7s0i0eSH8TCKiiQy/UThTb3qedK94aYuUDBNKrny 7fghEKUNDi9BaSzl6FHH0yHosmI0J/lakGr2O07bGz2IewWhIvgw/nBOOxeaCVp+p01y hbC/twsR6TdDYNEyDJ9j5HJZMrgUnlni7vMRAFgI7S1CLnPESrKaGx9Fc7Ab9CRoK1uk m3Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.de header.s=2017 header.b=LPmm0Pu3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.de Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id gi17-20020a17090b111100b0027491bac826si2321307pjb.140.2023.09.21.13.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 13:32:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@posteo.de header.s=2017 header.b=LPmm0Pu3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id A3A2B8344A16; Thu, 21 Sep 2023 10:13:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229823AbjIURM4 (ORCPT + 29 others); Thu, 21 Sep 2023 13:12:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230256AbjIURLn (ORCPT ); Thu, 21 Sep 2023 13:11:43 -0400 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8206FFF90 for ; Thu, 21 Sep 2023 10:06:17 -0700 (PDT) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 1BDAD240105 for ; Thu, 21 Sep 2023 11:22:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1695288120; bh=KlagOBJ/Znqi813S+2Fe679zuj+86NZUSO3PsTHMyNI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding:From; b=LPmm0Pu3SNgwlNsSM9gIxh1QJd1m67mMi2nH8+59Xx0X876YhVKTyvDWRDVg/LNzV kvM88FD6Aaio8GHeXEYaTYKvYNegD2TPLVcj5rp2mhwkNA/n+XinVFY/XrWmIqbG/H XKOGcM3hoGON5O6ZM0IXDPSu0HIs3B3ZvmUStgGwi5j/3+3DYnJpcC8+yD0GZv+Xhd U4WWZbh+0XCeT9Bl4dfbS67mNFNcRJ5bL/D8aF7AvqPZQeN8ACJZ03iTO1kc6B5SXb H+ApAzqv5lpkPeA47FuQtwi90ab2qzOh1Opu/82XtUqggj1zxQO+Mw6lFVV70vkeGO D6YVjNRBEo3vQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RrqfZ3sFWz9rxS; Thu, 21 Sep 2023 11:21:58 +0200 (CEST) From: Martin Kepplinger To: jikos@kernel.org, benjamin.tissoires@redhat.com, jm@lentin.co.uk, linux-kernel@vger.kernel.org Cc: linux-input@vger.kernel.org, Martin Kepplinger Subject: [PATCH] HID: lenovo: Fix middle-button behaviour for system suspend Date: Thu, 21 Sep 2023 09:21:40 +0000 Message-Id: <20230921092140.120533-1-martink@posteo.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 21 Sep 2023 10:13:11 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777680597033777155 X-GMAIL-MSGID: 1777680597033777155 After system suspend the middle-button mode is being reset to compatibility mode which simply breaks functionality for the devices where native mode is configured during probe(). Fix this by setting native mode in reset_resume() for the appropriate devices. Fixes: 94eefa271323 ("HID: lenovo: Use native middle-button mode for compact keyboards") Signed-off-by: Martin Kepplinger --- drivers/hid/hid-lenovo.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c index 44763c0da444..d20562b9eca6 100644 --- a/drivers/hid/hid-lenovo.c +++ b/drivers/hid/hid-lenovo.c @@ -1344,6 +1344,28 @@ static int lenovo_input_configured(struct hid_device *hdev, return 0; } +static int __maybe_unused lenovo_resume(struct hid_device *hdev) +{ + int ret; + + switch (hdev->product) { + case USB_DEVICE_ID_LENOVO_CUSBKBD: + case USB_DEVICE_ID_LENOVO_CBTKBD: + case USB_DEVICE_ID_LENOVO_TPIIUSBKBD: + case USB_DEVICE_ID_LENOVO_TPIIBTKBD: + /* Switch middle button to native mode again */ + ret = lenovo_send_cmd_cptkbd(hdev, 0x09, 0x01); + if (ret) + hid_warn(hdev, "Failed to switch middle button: %d\n", + ret); + break; + default: + ret = 0; + break; + } + + return ret; +} static const struct hid_device_id lenovo_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPKBD) }, @@ -1380,6 +1402,9 @@ static struct hid_driver lenovo_driver = { .raw_event = lenovo_raw_event, .event = lenovo_event, .report_fixup = lenovo_report_fixup, +#ifdef CONFIG_PM + .reset_resume = lenovo_resume, +#endif }; module_hid_driver(lenovo_driver);