mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: William Wu <william.wu@rock-chips.com>
Cc: Chris.Wulff@biamp.com, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, frank.wang@rock-chips.com,
	jianwei.zheng@rock-chips.com, yue.long@rock-chips.com
Subject: Re: [PATCH] usb: gadget: f_hid: Fix zero length packet transfer
Date: Fri, 22 Aug 2025 06:45:04 +0200	[thread overview]
Message-ID: <2025082235-fondness-destruct-f8f6@gregkh> (raw)
In-Reply-To: <1755828118-21640-1-git-send-email-william.wu@rock-chips.com>

On Fri, Aug 22, 2025 at 10:01:58AM +0800, William Wu wrote:
> If the hid transfer with size divisible to EPs max packet
> size, it needs to set the req->zero to true, then the usb
> controller can transfer a zero length packet at the end
> according to the USB 2.0 spec.
> 
> Signed-off-by: William Wu <william.wu@rock-chips.com>
> ---
>  drivers/usb/gadget/function/f_hid.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
> index 8e1d1e8..8021af3 100644
> --- a/drivers/usb/gadget/function/f_hid.c
> +++ b/drivers/usb/gadget/function/f_hid.c
> @@ -511,7 +511,7 @@ static ssize_t f_hidg_write(struct file *file, const char __user *buffer,
>  	}
>  
>  	req->status   = 0;
> -	req->zero     = 0;
> +	req->zero     = ((count % hidg->in_ep->maxpacket) == 0);
>  	req->length   = count;
>  	req->complete = f_hidg_req_complete;
>  	req->context  = hidg;
> @@ -967,7 +967,7 @@ static int hidg_setup(struct usb_function *f,
>  	return -EOPNOTSUPP;
>  
>  respond:
> -	req->zero = 0;
> +	req->zero = ((length % cdev->gadget->ep0->maxpacket) == 0);
>  	req->length = length;
>  	status = usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC);
>  	if (status < 0)

What commit id does this fix?

thanks,

greg k-h

  reply	other threads:[~2025-08-22  4:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-22  2:01 William Wu
2025-08-22  4:45 ` Greg KH [this message]
2025-08-22  8:45   ` wuliangfeng
2025-08-22 13:56 ` Alan Stern
2025-08-25  3:35   ` William Wu

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=2025082235-fondness-destruct-f8f6@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=Chris.Wulff@biamp.com \
    --cc=frank.wang@rock-chips.com \
    --cc=jianwei.zheng@rock-chips.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=william.wu@rock-chips.com \
    --cc=yue.long@rock-chips.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®