[PATCH] HID: usbhid: enable remote wakeup for mouse

huanglei814 posted 1 patch 1 year, 8 months ago
drivers/hid/usbhid/hid-core.c | 9 +++++++++
1 file changed, 9 insertions(+)
[PATCH] HID: usbhid: enable remote wakeup for mouse
Posted by huanglei814 1 year, 8 months ago
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
Re: [PATCH] HID: usbhid: enable remote wakeup for mouse
Posted by Greg KH 1 year, 8 months ago
On Wed, May 22, 2024 at 05:22:57PM +0800, huanglei814 wrote:
> From: huanglei <huanglei@kylinos.cn>
> 
> This patch enables remote wakeup by default for USB mouse
> devices.

That is not a good idea.  Please see the mailing list archives for the
past 20+ years for why this is the way it is.

If you know your device can support this, please set it in userspace,
but we can not change the default value at this point in time, sorry.

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

And that is really not a wise choice, boot protocol mice have no
requirement that they support remote wakeup.  So restricting it like
this really will not help, sorry.

Again, do this in userspace, that's why the interface is there to do so.

greg k-h
Re: [PATCH] HID: usbhid: enable remote wakeup for mouse
Posted by Oliver Neukum 1 year, 8 months ago
On 22.05.24 11:22, huanglei814 wrote:
> 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).

Hi,

could you explain in the log why you want this to depend
on support for the boot protocol?

	Regards
		Oliver
Re: [PATCH] HID: usbhid: enable remote wakeup for mouse
Posted by huanglei 1 year, 8 months ago
Just wanted to support mouse  wake up.

Set it in userspace will be a better choice, Now,canceled the patch.



在 2024/5/22 18:00, Oliver Neukum 写道:
> On 22.05.24 11:22, huanglei814 wrote:
>> 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).
>
> Hi,
>
> could you explain in the log why you want this to depend
> on support for the boot protocol?
>
>     Regards
>         Oliver