Skip to contentSkip to conversation

patch "usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers" added to usb-linus

PATCH [email protected] 2 participants 5 messages Jul 27, 2021

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers

to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-linus branch.

The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)

The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.

If you have any questions about this process, please let me know.

From afcff6dc690e24d636a41fd4bee6057e7c70eebd Mon Sep 17 00:00:00 2001
From: Maxim Devaev <[email protected]>
Date: Wed, 21 Jul 2021 21:03:51 +0300
Subject: usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers

The USB HID standard declares mandatory support for GET_IDLE and SET_IDLE requests for Boot Keyboard. Most hosts can handle their absence, but others like some old/strange UEFIs and BIOSes consider this a critical error and refuse to work with f_hid.

This primitive implementation of saving and returning idle is sufficient to meet the requirements of the standard and these devices.

---
 drivers/usb/gadget/function/f_hid.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/usb/gadget/function/f_hid.c +18 -0
index 08e73e8127b1..8d50c8b127fd 100644
@@ -41,6 +41,7 @@ struct f_hidg {
 	unsigned char			bInterfaceSubClass;
 	unsigned char			bInterfaceProtocol;
 	unsigned char			protocol;
+	unsigned char			idle;
 	unsigned short			report_desc_length;
 	char				*report_desc;
 	unsigned short			report_length;
@@ -537,6 +538,14 @@ static int hidg_setup(struct usb_function *f,
 		goto respond;
 		break;
 
+	case ((USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
+		  | HID_REQ_GET_IDLE):
+		VDBG(cdev, "get_idle\n");
+		length = min_t(unsigned int, length, 1);
+		((u8 *) req->buf)[0] = hidg->idle;
+		goto respond;
+		break;
+
 	case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
 		  | HID_REQ_SET_REPORT):
 		VDBG(cdev, "set_report | wLength=%d\n", ctrl->wLength);
@@ -560,6 +569,14 @@ static int hidg_setup(struct usb_function *f,
 		goto stall;
 		break;
 
+	case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
+		  | HID_REQ_SET_IDLE):
+		VDBG(cdev, "set_idle\n");
+		length = 0;
+		hidg->idle = value;
+		goto respond;
+		break;
+
 	case ((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8
 		  | USB_REQ_GET_DESCRIPTOR):
 		switch (value >> 8) {
@@ -787,6 +804,7 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f)
 	hidg_interface_desc.bInterfaceSubClass = hidg->bInterfaceSubClass;
 	hidg_interface_desc.bInterfaceProtocol = hidg->bInterfaceProtocol;
 	hidg->protocol = HID_REPORT_PROTOCOL;
+	hidg->idle = 1;
 	hidg_ss_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length);
 	hidg_ss_in_comp_desc.wBytesPerInterval =
 				cpu_to_le16(hidg->report_length);
Signature · 1 line
2.32.0
#1 lore raw

drivers/usb/gadget/function/f_hid.c static int hidg_setup(struct usb_function *f, · line 576

Quoted 7 lines

<[email protected]> wrote:
This is a note to let you know that I've just added the patch titled

usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers

to my usb git tree which can be found at

drivers/usb/gadget/function/f_hid.c +1 -0
+		hidg->idle = value;

Please use the second version of the patch from the thread.
During the discussion, we found out that value should be shifted 8 bits to the right.

https://www.spinics.net/lists/linux-usb/msg214841.html

author maintainer
#2 lore raw
Quoted 5 lines · Maxim Devaev
Quoted 5 lines

<[email protected]> wrote:
This is a note to let you know that I've just added the patch titled

usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers

Quoted 7 lines

drivers/usb/gadget/function/f_hid.c static int hidg_setup(struct usb_function *f, · line 576

Quoted 2 lines

to my usb git tree which can be found at

drivers/usb/gadget/function/f_hid.c +1 -0
+		hidg->idle = value;

Please use the second version of the patch from the thread.
During the discussion, we found out that value should be shifted 8 bits to the right.

https://www.spinics.net/lists/linux-usb/msg214841.html

Can you provide a lore.kernel.org link?

Wait, I can't take a patch in the middle of a thread, that's horrid.

Please just send a fix patch on top of what I took.

thanks,

greg k-h

author maintainer
#3 lore raw
In reply to Maxim Devaev
Quoted 5 lines · Maxim Devaev
Quoted 5 lines

<[email protected]> wrote:
This is a note to let you know that I've just added the patch titled

usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers

Quoted 7 lines

drivers/usb/gadget/function/f_hid.c static int hidg_setup(struct usb_function *f, · line 576

Quoted 2 lines

to my usb git tree which can be found at

drivers/usb/gadget/function/f_hid.c +1 -0
+		hidg->idle = value;

Please use the second version of the patch from the thread.
During the discussion, we found out that value should be shifted 8 bits to the right.

https://www.spinics.net/lists/linux-usb/msg214841.html

Also, that was no way to show a "v2" of a patch, no wonder I was confused, please in the future, do it in the documented way so our tools properly pick it up.

thanks,

greg k-h

#4 lore raw
Quoted 4 lines

Greg KH <[email protected]> wrote:
Also, that was no way to show a "v2" of a patch, no wonder I was confused, please in the future, do it in the documented way so our tools properly pick it up.

Sorry, that patch was my first time, I got a little confused in the process.

Thank you for explaining. I sent the v2 for this.