Re: [PATCH 02/23] usb: gadget: f_sourcesink: compute req size once

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 03, 2015 at 01:53:41PM +0100, Robert Baldyga wrote:
> Compute request size once before the loop instead of computing it in each
> loop iteration.
> 
> Signed-off-by: Robert Baldyga <r.baldyga@xxxxxxxxxxx>
> ---
>  drivers/usb/gadget/function/f_sourcesink.c | 45 +++++++++++++++---------------
>  1 file changed, 22 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c
> index 1d6ec88..a8b68c6 100644
> --- a/drivers/usb/gadget/function/f_sourcesink.c
> +++ b/drivers/usb/gadget/function/f_sourcesink.c
> @@ -591,31 +591,30 @@ static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in,
>  {
>  	struct usb_ep		*ep;
>  	struct usb_request	*req;
> -	int			i, size, status;
> -
> -	for (i = 0; i < 8; i++) {
> -		if (is_iso) {
> -			switch (speed) {
> -			case USB_SPEED_SUPER:
> -				size = ss->isoc_maxpacket *
> -						(ss->isoc_mult + 1) *
> -						(ss->isoc_maxburst + 1);
> -				break;
> -			case USB_SPEED_HIGH:
> -				size = ss->isoc_maxpacket * (ss->isoc_mult + 1);
> -				break;
> -			default:
> -				size = ss->isoc_maxpacket > 1023 ?
> -						1023 : ss->isoc_maxpacket;
> -				break;
> -			}
> -			ep = is_in ? ss->iso_in_ep : ss->iso_out_ep;
> -			req = ss_alloc_ep_req(ep, size);
> -		} else {
> -			ep = is_in ? ss->in_ep : ss->out_ep;
> -			req = ss_alloc_ep_req(ep, 0);
> +	int			i, size = 0, status;
> +
> +	if (is_iso) {
> +		switch (speed) {
> +		case USB_SPEED_SUPER:
> +			size = ss->isoc_maxpacket *
> +				(ss->isoc_mult + 1) *
> +				(ss->isoc_maxburst + 1);
> +			break;
> +		case USB_SPEED_HIGH:
> +			size = ss->isoc_maxpacket * (ss->isoc_mult + 1);
> +			break;
> +		default:
> +			size = ss->isoc_maxpacket > 1023 ?
> +				1023 : ss->isoc_maxpacket;
> +			break;
>  		}
> +		ep = is_in ? ss->iso_in_ep : ss->iso_out_ep;
> +	} else {
> +		ep = is_in ? ss->in_ep : ss->out_ep;
> +	}
>  
> +	for (i = 0; i < 8; i++) {
> +		req = ss_alloc_ep_req(ep, size);
>  		if (!req)
>  			return -ENOMEM;
>  

Reviewed-by: Peter Chen <peter.chen@xxxxxxxxxxxxx>

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux