linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: usbhid: enable remote wakeup for mouse
@ 2024-05-22  9:22 huanglei814
  2024-05-22 10:00 ` Oliver Neukum
  2024-05-22 11:23 ` Greg KH
  0 siblings, 2 replies; 8+ messages in thread
From: huanglei814 @ 2024-05-22  9:22 UTC (permalink / raw)
  To: jikos, bentiss; +Cc: linux-usb, linux-input, linux-kernel, huanglei

From: huanglei <huanglei@kylinos.cn>

This patch enables remote wakeup by default for USB mouse
devices.  Mouse can used 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: huanglei <huanglei@kylinos.cn>
---
 drivers/hid/usbhid/hid-core.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index a90ed2ceae84..7ed3ab36426d 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1189,6 +1189,15 @@ static int usbhid_start(struct hid_device *hid)
 		device_set_wakeup_enable(&dev->dev, 1);
 	}
 
+	/* 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;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [PATCH] HID: usbhid: enable remote wakeup for mouse
@ 2021-05-17  6:01 Qiang Ma
  2021-05-17  8:31 ` Oliver Neukum
  2021-05-17  8:58 ` Greg KH
  0 siblings, 2 replies; 8+ messages in thread
From: Qiang Ma @ 2021-05-17  6:01 UTC (permalink / raw)
  To: jikos, benjamin.tissoires, linux-usb; +Cc: linux-input, linux-kernel, Qiang Ma

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




^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-05-24  3:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-22  9:22 [PATCH] HID: usbhid: enable remote wakeup for mouse huanglei814
2024-05-22 10:00 ` Oliver Neukum
2024-05-24  3:14   ` huanglei
2024-05-22 11:23 ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2021-05-17  6:01 Qiang Ma
2021-05-17  8:31 ` Oliver Neukum
2021-05-17 13:32   ` Alan Stern
2021-05-17  8:58 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).