Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754301AbbKCNBl (ORCPT ); Tue, 3 Nov 2015 08:01:41 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:55348 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753300AbbKCMyl (ORCPT ); Tue, 3 Nov 2015 07:54:41 -0500 X-AuditID: cbfee61a-f79a06d000005c6f-8f-5638ae7e5f0e From: Robert Baldyga To: balbi@ti.com Cc: gregkh@linuxfoundation.org, andrzej.p@samsung.com, m.szyprowski@samsung.com, b.zolnierkie@samsung.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Robert Baldyga Subject: [PATCH 02/23] usb: gadget: f_sourcesink: compute req size once Date: Tue, 03 Nov 2015 13:53:41 +0100 Message-id: <1446555242-3733-3-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1446555242-3733-1-git-send-email-r.baldyga@samsung.com> References: <1446555242-3733-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMLMWRmVeSWpSXmKPExsVy+t9jQd26dRZhBqc/sFvMetnOYrFxxnpW i4P36y2aF69ns7i8aw6bxaJlrcwWa4/cZbd4cHgnuwOHx/65a9g9+rasYvQ4fmM7k8fnTXIB LFFcNimpOZllqUX6dglcGWcWLGIq+MZXsWzScrYGxi3cXYycHBICJhIXrp9ihLDFJC7cW88G YgsJzGKUmPrFpouRC8j+ySjxsukLM0iCTUBHYsv3CWANIgICEutfXGIHKWIWOMco8fBOG1CC g0NYwF3i5gd3kBoWAVWJbwt+sILYvAIuEjtn3mGCWCYncfLYZFaQck4BV4lL75RBTCGgkuPb eSYw8i5gZFjFKJFakFxQnJSea5iXWq5XnJhbXJqXrpecn7uJERxUz6R2MB7c5X6IUYCDUYmH d8ES8zAh1sSy4srcQ4wSHMxKIry751qECfGmJFZWpRblxxeV5qQWH2KU5mBREufV9zQKExJI TyxJzU5NLUgtgskycXBKNTA62kuc9TS4p7LurGLrj5mpeyRLBN2v5K4/+zgvm/3Ey/QzOuVV DVrHXLMrfxkxsnZERU744CPRJ/DhTvdT0XsN0RLTMvmZfpYVbb4X8znghXTnGqXrIlu5Lq77 b3jF4FPXtEN+6lYyR2VVznEoNC79I8O6wOKk6p37k00/cE4J1SwJLTPb+USJpTgj0VCLuag4 EQDmImj1JgIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2086 Lines: 74 Compute request size once before the loop instead of computing it in each loop iteration. Signed-off-by: Robert Baldyga --- 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; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/