All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qiang Ma <maqianga@uniontech.com>
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 <maqianga@uniontech.com>
Subject: [PATCH] HID: usbhid: enable remote wakeup for mouse
Date: Mon, 17 May 2021 14:01:45 +0800	[thread overview]
Message-ID: <20210517060145.32359-1-maqianga@uniontech.com> (raw)

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 <maqianga@uniontech.com>
---
 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:	
-- 
2.20.1




             reply	other threads:[~2021-05-17  6:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17  6:01 Qiang Ma [this message]
2021-05-17  8:31 ` [PATCH] HID: usbhid: enable remote wakeup for mouse Oliver Neukum
2021-05-17 13:32   ` Alan Stern
     [not found]     ` <1209199573.51584.1621492845444.JavaMail.xmail@bj-wm-cp-1>
2021-05-25  9:55       ` Oliver Neukum
2021-05-17  8:58 ` Greg KH
     [not found]   ` <1547909475.114060.1621244274064.JavaMail.xmail@bj-wm-cp-4>
2021-05-17  9:46     ` Greg KH
     [not found]       ` <1781917892.119659.1621247946603.JavaMail.xmail@bj-wm-cp-4>
2021-05-17 10:42         ` Greg KH
     [not found]           ` <440071991.120491.1621248757251.JavaMail.xmail@bj-wm-cp-4>
2021-05-17 11:19             ` Greg KH
     [not found]               ` <671637326.122188.1621250895330.JavaMail.xmail@bj-wm-cp-4>
2021-05-17 11:44                 ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210517060145.32359-1-maqianga@uniontech.com \
    --to=maqianga@uniontech.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.