lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230222013944.31095-1-michael@allwinnertech.com>
Date:   Wed, 22 Feb 2023 09:39:44 +0800
From:   Michael Wu <michael@...winnertech.com>
To:     jikos@...nel.org, benjamin.tissoires@...hat.com
Cc:     linux-usb@...r.kernel.org, linux-input@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH] HID: usbhid: enable remote wakeup for mice

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@...winnertech.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ