From patchwork Mon May 17 06:01:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Ma X-Patchwork-Id: 441660 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E71EC43461 for ; Mon, 17 May 2021 06:03:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C78561206 for ; Mon, 17 May 2021 06:03:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232532AbhEQGFA (ORCPT ); Mon, 17 May 2021 02:05:00 -0400 Received: from lucky1.263xmail.com ([211.157.147.132]:55276 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231775AbhEQGFA (ORCPT ); Mon, 17 May 2021 02:05:00 -0400 Received: from localhost (unknown [192.168.167.32]) by lucky1.263xmail.com (Postfix) with ESMTP id 8B79DF3F9D; Mon, 17 May 2021 14:03:27 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED4: 1 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [124.126.19.250]) by smtp.263.net (postfix) whith ESMTP id P18566T140528154826496S1621231401053565_; Mon, 17 May 2021 14:03:27 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <240da64eecbce62dcea6f5674607e489> X-RL-SENDER: maqianga@uniontech.com X-SENDER: maqianga@uniontech.com X-LOGIN-NAME: maqianga@uniontech.com X-FST-TO: jikos@kernel.org X-RCPT-COUNT: 6 X-SENDER-IP: 124.126.19.250 X-ATTACHMENT-NUM: 0 X-System-Flag: 0 From: Qiang Ma To: jikos@kernel.org, benjamin.tissoires@redhat.com, linux-usb@vger.kernel.org Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Qiang Ma Subject: [PATCH] HID: usbhid: enable remote wakeup for mouse Date: Mon, 17 May 2021 14:01:45 +0800 Message-Id: <20210517060145.32359-1-maqianga@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This patch enables remote wakeup by default for USB mouse devices. Mouse in general are supposed to be wakeup devices, but the correct place to enable it depends on the device's bus; no single approach will work for all mouse devices. In particular, this covers only USB mouse (and then only those supporting the boot protocol). Signed-off-by: Qiang Ma --- drivers/hid/usbhid/hid-core.c | 12 +++++++----- drivers/hid/usbhid/usbmouse.c | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 86257ce6d619..592aa57a97f5 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -1186,11 +1186,13 @@ static int usbhid_start(struct hid_device *hid) * In addition, enable remote wakeup by default for all keyboard * devices supporting the boot protocol. */ - if (interface->desc.bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT && - interface->desc.bInterfaceProtocol == - USB_INTERFACE_PROTOCOL_KEYBOARD) { - usbhid_set_leds(hid); - device_set_wakeup_enable(&dev->dev, 1); + if (interface->desc.bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT) { + if (interface->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_KEYBOARD || + interface->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_MOUSE) { + if (interface->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_KEYBOARD) + usbhid_set_leds(hid); + device_set_wakeup_enable(&dev->dev, 1); + } } mutex_unlock(&usbhid->mutex); diff --git a/drivers/hid/usbhid/usbmouse.c b/drivers/hid/usbhid/usbmouse.c index 073127e65ac1..cf785369a5ed 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: