[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20151106030749.GC12560@shlinux2>
Date: Fri, 6 Nov 2015 11:07:50 +0800
From: Peter Chen <peter.chen@...escale.com>
To: Robert Baldyga <r.baldyga@...sung.com>
CC: <balbi@...com>, <gregkh@...uxfoundation.org>,
<andrzej.p@...sung.com>, <m.szyprowski@...sung.com>,
<b.zolnierkie@...sung.com>, <linux-usb@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 02/23] usb: gadget: f_sourcesink: compute req size once
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@...sung.com>
> ---
> 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@...escale.com>
--
Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists