lkml.org 
[lkml]   [2021]   [Dec]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v1 1/2] HID: usbhid: enable remote wakeup function for usbhid device
Date
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
\
 
 \ /
  Last update: 2021-12-08 10:40    [W:0.175 / U:1.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site