From patchwork Wed Feb 22 01:39:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Wu X-Patchwork-Id: 60302 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp326858wrd; Tue, 21 Feb 2023 17:43:59 -0800 (PST) X-Google-Smtp-Source: AK7set/yZsvUJVUpPOkfUyLAHdII4srbfpJUL4RPtjUK99bVpKosrXhPhomIF+fnQMvBvCnxnaQq X-Received: by 2002:a17:906:34da:b0:8aa:af33:72d6 with SMTP id h26-20020a17090634da00b008aaaf3372d6mr14250048ejb.45.1677030239019; Tue, 21 Feb 2023 17:43:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677030239; cv=none; d=google.com; s=arc-20160816; b=pYby7kNIkkSBnrM7xuc0CDF7l8XPouHet/xZku5+mgyoxAnsGcgBBHeGfaYR0010vG 1jhlbSvZYtC4LLKgeVG66tP51sM43IDyUPfC5t3Usbl9KZ049jkJ7C/9TNryYGRjX8tE Z9neMJiC7oGfG8AaD24xMvoDmny3PDV+/NidAOi6uJDZEepQaADyZ9Q2WWNpVk73WH1R MCfFQTZtVbPswmWu8pm5XLayRtod7wHIWnsVExSVRTYp6Lo0dWKT9QfvwR9Fg9k+8CZr 3mzqYkrjGBT/aZhWy4CefgglazHKR/MnBuxyoiQK5u1Df2bpc7Tv86F1tyRSjCxLblO4 WLhw== 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=7t5aO3ExogaocqnZarFsWn5a04iWzPOlpiYSfgsqOXc=; b=pQk8ffpSmuqVPJbRViXN+Pfnab0Zzr9SY/rsePdcirsQ1zmSa0mXWhGQnMQXFtDjL+ bb7/ZCOg1SEUObGf71zxWGTl05+mpek0OLnx8zpgcSx9CNQE5NDtdYY7HSmw6585niu8 c9sDBefyZUXSwhrbGstLB032apmipZILHoEu4HHHDw+Ma0rDyX7TzAeXU1vYBgrLv/B2 UNKp60RUHDKqnxUpRbmqomvTiz/QmlD6ZpsJlkGz3FBuRi15fXrkbrk+Q+v1pC8LPLqo g1Gc/Pv/zP5LT7lT0NMHWlUIkt/zfx9/sn0yukdNBCw1S99anHCWGZa3iF3zC91bokIM TqeA== 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 h6-20020a170906530600b008c740508747si14963334ejo.586.2023.02.21.17.43.35; Tue, 21 Feb 2023 17:43:59 -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 S230043AbjBVBjE (ORCPT + 99 others); Tue, 21 Feb 2023 20:39:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229581AbjBVBjC (ORCPT ); Tue, 21 Feb 2023 20:39:02 -0500 Received: from out28-221.mail.aliyun.com (out28-221.mail.aliyun.com [115.124.28.221]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72A7F199DF; Tue, 21 Feb 2023 17:39:00 -0800 (PST) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.08688394|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_regular_dialog|0.00408143-0.000507876-0.995411;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047207;MF=michael@allwinnertech.com;NM=1;PH=DS;RN=5;RT=5;SR=0;TI=SMTPD_---.RTE644q_1677029937; Received: from SunxiBot.allwinnertech.com(mailfrom:michael@allwinnertech.com fp:SMTPD_---.RTE644q_1677029937) by smtp.aliyun-inc.com; Wed, 22 Feb 2023 09:38:57 +0800 From: Michael Wu To: jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-usb@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] HID: usbhid: enable remote wakeup for mice Date: Wed, 22 Feb 2023 09:39:44 +0800 Message-Id: <20230222013944.31095-1-michael@allwinnertech.com> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY 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?1758493660030512043?= X-GMAIL-MSGID: =?utf-8?q?1758493660030512043?= This patch fixes a problem that USB mouse can't wake up the device that enters standby. At present, the kernel only checks whether certain USB manufacturers support wake-up, which will easily cause inconvenience to the development work of other manufacturers and add unnecessary work to the maintenance of kernel. The USB protocol supports judging whether a usb supports the wake-up function, so it should be more reasonable to add a wake-up source by directly checking the settings from the USB protocol. There was a similar issue on the keyboard before, which was fixed by this patch (3d61510f4eca), but now the problem happened on the mouse. This patch uses a similar idea to fix this problem. Signed-off-by: Michael Wu --- drivers/hid/usbhid/hid-core.c | 8 ++++++++ drivers/hid/usbhid/usbmouse.c | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index be4c731aaa65..d3a6755cca09 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -1189,6 +1189,14 @@ static int usbhid_start(struct hid_device *hid) device_set_wakeup_enable(&dev->dev, 1); } + /** + * NOTE: enable remote wakeup by default for all mouse devices + * supporting the boot protocol. + */ + if (interface->desc.bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT && + interface->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_MOUSE) + device_set_wakeup_enable(&dev->dev, 1); + mutex_unlock(&usbhid->mutex); return 0; diff --git a/drivers/hid/usbhid/usbmouse.c b/drivers/hid/usbhid/usbmouse.c index 3fd93c2e4f4a..2fbc3f49e420 100644 --- a/drivers/hid/usbhid/usbmouse.c +++ b/drivers/hid/usbhid/usbmouse.c @@ -188,6 +188,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i goto fail3; usb_set_intfdata(intf, mouse); + device_set_wakeup_enable(&dev->dev, 1); return 0; fail3: