LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v2] usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers
@ 2021-07-27 18:31 Maxim Devaev
  2021-07-27 18:45 ` Greg KH
  2021-07-27 18:46 ` Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: Maxim Devaev @ 2021-07-27 18:31 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, sandeen, mdevaev, linux-usb, linux-kernel

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.

Signed-off-by: Maxim Devaev <mdevaev@gmail.com>
---
 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 02683ac07..1010f0a3e 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;
@@ -523,6 +524,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);
@@ -546,6 +555,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 >> 8;
+		goto respond;
+		break;
+
 	case ((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8
 		  | USB_REQ_GET_DESCRIPTOR):
 		switch (value >> 8) {
@@ -773,6 +790,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	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers
  2021-07-27 18:31 [PATCH v2] usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers Maxim Devaev
@ 2021-07-27 18:45 ` Greg KH
  2021-07-27 18:46 ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2021-07-27 18:45 UTC (permalink / raw)
  To: Maxim Devaev; +Cc: balbi, sandeen, linux-usb, linux-kernel

On Tue, Jul 27, 2021 at 09:31:41PM +0300, Maxim Devaev wrote:
> 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.
> 
> Signed-off-by: Maxim Devaev <mdevaev@gmail.com>
> ---
>  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 02683ac07..1010f0a3e 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;
> @@ -523,6 +524,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);
> @@ -546,6 +555,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 >> 8;
> +		goto respond;
> +		break;
> +
>  	case ((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8
>  		  | USB_REQ_GET_DESCRIPTOR):
>  		switch (value >> 8) {
> @@ -773,6 +790,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
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- You sent a patch that has been sent multiple times in the past few
  days, and is identical to ones that has been recently rejected.
  Please always look at the mailing list traffic to determine if you are
  duplicating other people's work.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

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

* Re: [PATCH v2] usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers
  2021-07-27 18:31 [PATCH v2] usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers Maxim Devaev
  2021-07-27 18:45 ` Greg KH
@ 2021-07-27 18:46 ` Greg KH
  2021-07-27 18:59   ` Maxim Devaev
  1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2021-07-27 18:46 UTC (permalink / raw)
  To: Maxim Devaev; +Cc: balbi, sandeen, linux-usb, linux-kernel

On Tue, Jul 27, 2021 at 09:31:41PM +0300, Maxim Devaev wrote:
> 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.
> 
> Signed-off-by: Maxim Devaev <mdevaev@gmail.com>
> ---
>  drivers/usb/gadget/function/f_hid.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)

As I already took your first patch, and I can not drop it as it is a
public tree, can you just send me the fixup patch?  That would be
simpler than me reverting the original and then applying a "fixed"
version, right?

thanks,

greg k-h

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

* Re: [PATCH v2] usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers
  2021-07-27 18:46 ` Greg KH
@ 2021-07-27 18:59   ` Maxim Devaev
  0 siblings, 0 replies; 4+ messages in thread
From: Maxim Devaev @ 2021-07-27 18:59 UTC (permalink / raw)
  To: Greg KH; +Cc: balbi, sandeen, linux-usb, linux-kernel

> Greg KH <gregkh@linuxfoundation.org> wrote:
> As I already took your first patch, and I can not drop it as it is a
> public tree, can you just send me the fixup patch?  That would be
> simpler than me reverting the original and then applying a "fixed"
> version, right?

Sure. Sent a fix as ("usb: gadget: f_hid: idle uses the highest byte for duration").

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

end of thread, other threads:[~2021-07-27 19:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27 18:31 [PATCH v2] usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers Maxim Devaev
2021-07-27 18:45 ` Greg KH
2021-07-27 18:46 ` Greg KH
2021-07-27 18:59   ` Maxim Devaev

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