linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: usbhid: enable remote wakeup for mice
@ 2011-10-14  7:54 Benson Leung
  2011-10-14  8:18 ` Oliver Neukum
  0 siblings, 1 reply; 26+ messages in thread
From: Benson Leung @ 2011-10-14  7:54 UTC (permalink / raw)
  To: jkosina, stern, linux-usb, linux-input, linux-kernel; +Cc: bleung

This patch enables remote wakeup by default on USB mouse
devices. This only covers USB mice that support
the boot protocol. See commit 3d61510f for the
equivalent patch for USB keyboard devices.

Signed-off-by: Benson Leung <bleung@chromium.org>
---
 drivers/hid/usbhid/hid-core.c |    8 ++++----
 drivers/hid/usbhid/usbmouse.c |    1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index b403fce..02a66f1 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1073,10 +1073,10 @@ 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);
+	if (interface->desc.bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT) {
+		if (interface->desc.bInterfaceProtocol ==
+				USB_INTERFACE_PROTOCOL_KEYBOARD)
+			usbhid_set_leds(hid);
 		device_set_wakeup_enable(&dev->dev, 1);
 	}
 	return 0;
diff --git a/drivers/hid/usbhid/usbmouse.c b/drivers/hid/usbhid/usbmouse.c
index 79b2bf8..6ca3321 100644
--- a/drivers/hid/usbhid/usbmouse.c
+++ b/drivers/hid/usbhid/usbmouse.c
@@ -200,6 +200,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:	
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread
* [PATCH] HID: usbhid: enable remote wakeup for mice
@ 2023-02-22  1:39 Michael Wu
  2023-02-22  6:04 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Michael Wu @ 2023-02-22  1:39 UTC (permalink / raw)
  To: jikos, benjamin.tissoires; +Cc: linux-usb, linux-input, linux-kernel

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 <michael@allwinnertech.com>
---
 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:	
-- 
2.29.0


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

end of thread, other threads:[~2023-02-28 19:08 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-14  7:54 [PATCH] HID: usbhid: enable remote wakeup for mice Benson Leung
2011-10-14  8:18 ` Oliver Neukum
2011-10-14 13:56   ` Alan Stern
2011-10-14 14:00     ` Jiri Kosina
2011-10-14 14:58       ` Benson Leung
2011-10-14 15:09         ` Alan Stern
     [not found]           ` <Pine.LNX.4.44L0.1110141106270.2036-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2011-10-15  9:43             ` Oliver Neukum
2011-10-15 19:07               ` Alan Stern
  -- strict thread matches above, loose matches on Subject: below --
2023-02-22  1:39 Michael Wu
2023-02-22  6:04 ` Greg KH
2023-02-22 19:50   ` Limonciello, Mario
2023-02-23 11:41     ` Oliver Neukum
2023-02-23 11:18   ` Michael Wu
2023-02-23 11:23     ` Greg KH
2023-02-23 12:01       ` Oliver Neukum
2023-02-23 19:41         ` Limonciello, Mario
2023-02-28  9:03           ` Oliver Neukum
2023-02-28 18:50             ` Limonciello, Mario
2023-02-28 19:05               ` Greg KH
2023-02-28 19:07                 ` Limonciello, Mario
2023-02-24  7:02       ` Michael Wu
2023-02-22  8:59 ` Sergei Shtylyov
2023-02-23  4:01   ` Michael Wu
2023-02-22  9:34 ` Oliver Neukum
2023-02-23 11:22   ` Michael Wu
2023-02-23 11:47     ` Oliver Neukum

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).