linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] HID: usbhid: enable remote wakeup function for usbhid device
@ 2021-12-08  9:39 Yinbo Zhu
  2021-12-08  9:39 ` [PATCH v1 2/2] usb: core: enable remote wakeup function for usb controller Yinbo Zhu
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Yinbo Zhu @ 2021-12-08  9:39 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Greg Kroah-Hartman,
	Thinh Nguyen, Mathias Nyman, Alan Stern, Rajat Jain, Chris Chiu,
	linux-usb, linux-input, linux-kernel
  Cc: Yinbo Zhu

The remote wake-up function is a regular function on usb hid device
and I think keeping it enabled by default will make usb application
more convenient. This patch is to enable remote wakeup function for
usb hid device.

Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
---
 drivers/hid/usbhid/hid-core.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 2dcaf31..3619b95 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1063,7 +1063,9 @@ static int usbhid_start(struct hid_device *hid)
 	struct usb_host_interface *interface = intf->cur_altsetting;
 	struct usb_device *dev = interface_to_usbdev(intf);
 	struct usbhid_device *usbhid = hid->driver_data;
+	struct usb_host_config *config;
 	unsigned int n, insize = 0;
+	int ncfg;
 	int ret;
 
 	mutex_lock(&usbhid->mutex);
@@ -1179,14 +1181,19 @@ static int usbhid_start(struct hid_device *hid)
 	/* Some keyboards don't work until their LEDs have been set.
 	 * Since BIOSes do set the LEDs, it must be safe for any device
 	 * that supports the keyboard boot protocol.
-	 * 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);
+	}
+
+	for (ncfg = 0; ncfg < dev->descriptor.bNumConfigurations; ncfg++) {
+		config = &dev->config[ncfg];
+		if ((config->desc.bmAttributes & (1 << 5)) == 0)
+			break;
+		if (ncfg + 1 == dev->descriptor.bNumConfigurations)
+			device_set_wakeup_enable(&dev->dev, 1);
 	}
 
 	mutex_unlock(&usbhid->mutex);
-- 
1.8.3.1


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

end of thread, other threads:[~2022-01-04 11:44 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-08  9:39 [PATCH v1 1/2] HID: usbhid: enable remote wakeup function for usbhid device Yinbo Zhu
2021-12-08  9:39 ` [PATCH v1 2/2] usb: core: enable remote wakeup function for usb controller Yinbo Zhu
2021-12-08 14:10   ` kernel test robot
2021-12-08 22:04   ` Alan Stern
2021-12-10  9:27     ` zhuyinbo
2021-12-10 16:35       ` Alan Stern
2021-12-08 10:03 ` [PATCH v1 1/2] HID: usbhid: enable remote wakeup function for usbhid device Oliver Neukum
2021-12-10  9:50   ` zhuyinbo
2021-12-14 14:21     ` Oliver Neukum
2021-12-16 10:59       ` zhuyinbo
2021-12-16 12:42         ` Oliver Neukum
2022-01-04 11:44           ` zhuyinbo
2021-12-08 11:55 ` Greg Kroah-Hartman
2021-12-10  9:54   ` zhuyinbo
2021-12-10 10:45     ` Greg Kroah-Hartman
2021-12-16 11:40       ` zhuyinbo

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