From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Arthur Crépin Leblond" <arthur@marmottus.net>
Cc: linux-usb@vger.kernel.org, Ben Hoff <hoff.benjamin.k@gmail.com>
Subject: Re: [PATCH] usb: gadget: f_hid: convert polling interval from ms to bInterval units
Date: Fri, 17 Jul 2026 12:26:19 +0200 [thread overview]
Message-ID: <2026071728-riveter-finale-de15@gregkh> (raw)
In-Reply-To: <20260716144921.1120265-1-arthur@marmottus.net>
On Thu, Jul 16, 2026 at 04:49:21PM +0200, Arthur Crépin Leblond wrote:
> The HID polling interval is different depending on the USB speed.
>
> - Full speed: the units are milliseconds (1-255)
> - High/Super speed: the units are micro-frames of 0.125ms
>
> Exposing directly the bInterval means that the user needs to know
> which speed is currently in use and has to convert it accordingly
> themselves.
>
> The solution is to expose the interval in units of milliseconds and
> do the conversion in the driver.
>
> Cc: Ben Hoff <hoff.benjamin.k@gmail.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Arthur Crépin Leblond <arthur@marmottus.net>
> ---
> Documentation/ABI/testing/configfs-usb-gadget-hid | 10 ++++++++++
> drivers/usb/gadget/function/f_hid.c | 8 ++++----
> 2 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/ABI/testing/configfs-usb-gadget-hid b/Documentation/ABI/testing/configfs-usb-gadget-hid
> index 748705c4cb58..006d479b7428 100644
> --- a/Documentation/ABI/testing/configfs-usb-gadget-hid
> +++ b/Documentation/ABI/testing/configfs-usb-gadget-hid
> @@ -11,3 +11,13 @@ Description:
> report_length HID report length
> subclass HID device subclass to use
> ============= ============================================
> +
> +What: /config/usb-gadget/gadget/functions/hid.name/interval
> +Date: Jul 2026
> +KernelVersion: 7.2
> +Description:
> + The polling interval for the HID endpoint(s), expressed in
> + milliseconds in the range 1-255.
> +
> + The value is speed-independent: the driver converts it to the
> + appropriate bInterval.
> diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
> index 3c6b43d06a6d..49548a96c1e8 100644
> --- a/drivers/usb/gadget/function/f_hid.c
> +++ b/drivers/usb/gadget/function/f_hid.c
> @@ -1211,8 +1211,8 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f)
> hidg_ss_in_ep_desc.bInterval = 4;
> } else {
> hidg_fs_in_ep_desc.bInterval = hidg->interval;
> - hidg_hs_in_ep_desc.bInterval = hidg->interval;
> - hidg_ss_in_ep_desc.bInterval = hidg->interval;
> + hidg_hs_in_ep_desc.bInterval = USB_MS_TO_HS_INTERVAL(hidg->interval);
> + hidg_ss_in_ep_desc.bInterval = USB_MS_TO_HS_INTERVAL(hidg->interval);
> }
>
> hidg_ss_out_comp_desc.wBytesPerInterval =
> @@ -1245,8 +1245,8 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f)
> hidg_ss_out_ep_desc.bInterval = 4;
> } else {
> hidg_fs_out_ep_desc.bInterval = hidg->interval;
> - hidg_hs_out_ep_desc.bInterval = hidg->interval;
> - hidg_ss_out_ep_desc.bInterval = hidg->interval;
> + hidg_hs_out_ep_desc.bInterval = USB_MS_TO_HS_INTERVAL(hidg->interval);
> + hidg_ss_out_ep_desc.bInterval = USB_MS_TO_HS_INTERVAL(hidg->interval);
So this breaks the current usage, as the value previously used now
operates differently, right?
Yes, it was never documented, but by changing this, what are you now
causing to be changed when kernels are updated and userspace isn't
modified?
thanks,
greg k-h
next prev parent reply other threads:[~2026-07-17 10:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 14:49 [PATCH] usb: gadget: f_hid: convert polling interval from ms to bInterval units Arthur Crépin Leblond
2026-07-17 10:26 ` Greg Kroah-Hartman [this message]
2026-07-17 13:02 ` Arthur Crepin Leblond
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2026071728-riveter-finale-de15@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=arthur@marmottus.net \
--cc=hoff.benjamin.k@gmail.com \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.