* patch "usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers" added to usb-linus
@ 2021-07-27 13:55 gregkh
2021-07-27 18:07 ` Maxim Devaev
0 siblings, 1 reply; 5+ messages in thread
From: gregkh @ 2021-07-27 13:55 UTC (permalink / raw)
To: mdevaev, balbi, gregkh, stable
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 <mdevaev@gmail.com>
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.
Acked-by: Felipe Balbi <balbi@kernel.org>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Maxim Devaev <mdevaev@gmail.com>
Link: https://lore.kernel.org/r/20210721180351.129450-1-mdevaev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/gadget/function/f_hid.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index 08e73e8127b1..8d50c8b127fd 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -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);
--
2.32.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: patch "usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers" added to usb-linus
2021-07-27 13:55 patch "usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers" added to usb-linus gregkh
@ 2021-07-27 18:07 ` Maxim Devaev
2021-07-27 18:26 ` Greg KH
2021-07-27 18:27 ` Greg KH
0 siblings, 2 replies; 5+ messages in thread
From: Maxim Devaev @ 2021-07-27 18:07 UTC (permalink / raw)
To: gregkh; +Cc: balbi, stable
> <gregkh@linuxfoundation.org> 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
> + 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: patch "usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers" added to usb-linus
2021-07-27 18:07 ` Maxim Devaev
@ 2021-07-27 18:26 ` Greg KH
2021-07-27 18:27 ` Greg KH
1 sibling, 0 replies; 5+ messages in thread
From: Greg KH @ 2021-07-27 18:26 UTC (permalink / raw)
To: Maxim Devaev; +Cc: balbi, stable
On Tue, Jul 27, 2021 at 09:07:54PM +0300, Maxim Devaev wrote:
> > <gregkh@linuxfoundation.org> 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
> > + 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: patch "usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers" added to usb-linus
2021-07-27 18:07 ` Maxim Devaev
2021-07-27 18:26 ` Greg KH
@ 2021-07-27 18:27 ` Greg KH
2021-07-27 18:33 ` Maxim Devaev
1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2021-07-27 18:27 UTC (permalink / raw)
To: Maxim Devaev; +Cc: balbi, stable
On Tue, Jul 27, 2021 at 09:07:54PM +0300, Maxim Devaev wrote:
> > <gregkh@linuxfoundation.org> 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
> > + 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: patch "usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers" added to usb-linus
2021-07-27 18:27 ` Greg KH
@ 2021-07-27 18:33 ` Maxim Devaev
0 siblings, 0 replies; 5+ messages in thread
From: Maxim Devaev @ 2021-07-27 18:33 UTC (permalink / raw)
To: Greg KH; +Cc: balbi, stable
> Greg KH <gregkh@linuxfoundation.org> 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.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-07-27 18:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27 13:55 patch "usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers" added to usb-linus gregkh
2021-07-27 18:07 ` Maxim Devaev
2021-07-27 18:26 ` Greg KH
2021-07-27 18:27 ` Greg KH
2021-07-27 18:33 ` Maxim Devaev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.