public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Baldyga <r.baldyga@samsung.com>
To: balbi@ti.com
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, andrzej.p@samsung.com,
	b.zolnierkie@samsung.com
Subject: Re: [PATCH 2/2] usb: gadget: f_loopfack: fix function params handling
Date: Thu, 24 Sep 2015 17:18:17 +0200	[thread overview]
Message-ID: <56041439.9050407@samsung.com> (raw)
In-Reply-To: <1443106967-1972-3-git-send-email-r.baldyga@samsung.com>

Hi Felipe,

I see that Krzysztof Opasiak made the same change in patch
https://lkml.org/lkml/2015/9/22/578, so please just ignore my patch.

My first patch is still needed - I will resend it with CC: stable.

Thanks,
Robert Baldyga

On 09/24/2015 05:02 PM, Robert Baldyga wrote:
> Move function parameters to struct f_loopback to make them per instance
> instead of having them as global variables. Since we can have multiple
> instances of USB function we also want to have separate set of parameters
> for each instance.
> 
> Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
> ---
>  drivers/usb/gadget/function/f_loopback.c | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/f_loopback.c b/drivers/usb/gadget/function/f_loopback.c
> index 300e601..8d2dac8 100644
> --- a/drivers/usb/gadget/function/f_loopback.c
> +++ b/drivers/usb/gadget/function/f_loopback.c
> @@ -34,6 +34,9 @@ struct f_loopback {
>  
>  	struct usb_ep		*in_ep;
>  	struct usb_ep		*out_ep;
> +
> +	unsigned qlen;
> +	unsigned buflen;
>  };
>  
>  static inline struct f_loopback *func_to_loop(struct usb_function *f)
> @@ -41,9 +44,6 @@ static inline struct f_loopback *func_to_loop(struct usb_function *f)
>  	return container_of(f, struct f_loopback, function);
>  }
>  
> -static unsigned qlen;
> -static unsigned buflen;
> -
>  /*-------------------------------------------------------------------------*/
>  
>  static struct usb_interface_descriptor loopback_intf = {
> @@ -251,7 +251,7 @@ static void loopback_complete(struct usb_ep *ep, struct usb_request *req)
>  		}
>  
>  		/* queue the buffer for some later OUT packet */
> -		req->length = buflen;
> +		req->length = loop->buflen;
>  		status = usb_ep_queue(ep, req, GFP_ATOMIC);
>  		if (status == 0)
>  			return;
> @@ -288,7 +288,9 @@ static void disable_loopback(struct f_loopback *loop)
>  
>  static inline struct usb_request *lb_alloc_ep_req(struct usb_ep *ep, int len)
>  {
> -	return alloc_ep_req(ep, len, buflen);
> +	struct f_loopback	*loop = ep->driver_data;
> +
> +	return alloc_ep_req(ep, len, loop->buflen);
>  }
>  
>  static int enable_endpoint(struct usb_composite_dev *cdev, struct f_loopback *loop,
> @@ -315,7 +317,7 @@ static int enable_endpoint(struct usb_composite_dev *cdev, struct f_loopback *lo
>  	 * we buffer at most 'qlen' transfers; fewer if any need more
>  	 * than 'buflen' bytes each.
>  	 */
> -	for (i = 0; i < qlen && result == 0; i++) {
> +	for (i = 0; i < loop->qlen && result == 0; i++) {
>  		req = lb_alloc_ep_req(ep, 0);
>  		if (!req)
>  			goto fail1;
> @@ -388,10 +390,10 @@ static struct usb_function *loopback_alloc(struct usb_function_instance *fi)
>  	lb_opts->refcnt++;
>  	mutex_unlock(&lb_opts->lock);
>  
> -	buflen = lb_opts->bulk_buflen;
> -	qlen = lb_opts->qlen;
> -	if (!qlen)
> -		qlen = 32;
> +	loop->buflen = lb_opts->bulk_buflen;
> +	loop->qlen = lb_opts->qlen;
> +	if (!loop->qlen)
> +		loop->qlen = 32;
>  
>  	loop->function.name = "loopback";
>  	loop->function.bind = loopback_bind;
> 


      reply	other threads:[~2015-09-24 15:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-24 15:02 [PATCH 0/2] usb: gadget: fixes for f_sourcesink and f_loopback Robert Baldyga
2015-09-24 15:02 ` [PATCH 1/2] usb: gadget: f_sourcesink: fix function params handling Robert Baldyga
2015-09-24 15:02 ` [PATCH 2/2] usb: gadget: f_loopfack: " Robert Baldyga
2015-09-24 15:18   ` Robert Baldyga [this message]

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=56041439.9050407@samsung.com \
    --to=r.baldyga@samsung.com \
    --cc=andrzej.p@samsung.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=balbi@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox