Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031623AbbKFDJ5 (ORCPT ); Thu, 5 Nov 2015 22:09:57 -0500 Received: from mail-by2on0119.outbound.protection.outlook.com ([207.46.100.119]:59936 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1031061AbbKFDJz (ORCPT ); Thu, 5 Nov 2015 22:09:55 -0500 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=freescale.com; Date: Fri, 6 Nov 2015 11:07:50 +0800 From: Peter Chen To: Robert Baldyga CC: , , , , , , Subject: Re: [PATCH 02/23] usb: gadget: f_sourcesink: compute req size once Message-ID: <20151106030749.GC12560@shlinux2> References: <1446555242-3733-1-git-send-email-r.baldyga@samsung.com> <1446555242-3733-3-git-send-email-r.baldyga@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1446555242-3733-3-git-send-email-r.baldyga@samsung.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD032;1:3ayMAs8AQy8xO4bpN282ddk6THI29E0XKqNQoM1yJUEn21s3dLRckPtICTaOhlzCVUWd/TAtg0m0ja2+OYMLLy4NgXTF9pgZxmtfw7LJKLipVjKQu7A+MY8eQP8fAonWyXTbAMqhaPw0ocAInr9j7rvYD6mrTrUgSztSpyVbjGubKviRVLiVRvmr5gT/aVTCPmXr5ewwHP1Cb4JJkyP+U+XU7FTbFKHPBpvcepfSSB5KIIcvsIz1zuxQSVDNp9Usro+2i3jTb04MHHJY61nrBwJtcEg6dNnOz+VXfkkZ42NaERM3MTByjxuZAVGUUsPX5W2I35kmoDDtgbEJimhnYkUudkfyij6HuQwpXSkNAF5nPhO8PRkNQmeRFRUJaI2q X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(1109001)(1110001)(339900001)(24454002)(199003)(189002)(54356999)(92566002)(76176999)(47776003)(85426001)(33656002)(23726002)(87936001)(110136002)(189998001)(5001960100002)(97756001)(46406003)(19580395003)(83506001)(19580405001)(33716001)(105606002)(106466001)(86362001)(5008740100001)(6806005)(104016004)(2950100001)(81156007)(77096005)(11100500001)(97736004)(5007970100001)(4001350100001)(50986999)(50466002);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR0301MB2004;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BLUPR0301MB2004;2:ZoCaKrNJqxrML/AZJIEGQurLptCLVL1Nv93s2BPfEadw0j9HEnPeMSVYXJxKKLcbN4lCiSLCDd2sR7eN8aNdKAmil7MZXnfIzsr1D5n3wuqGJeYFuqvFq4XWLjeWKwzHCUGNmgOvB056sJt/GGCmwG+rLR+fzRaf2IpJCFamrl0=;3:2mhDVJ/VVUi5QZyLU2XBZuuNJM2racRWPPoqWVuiY1XmS2BxB54/8k8+904GUuac+uZEW6Rvmv6wmqkW2Owi5dTmlEZplvwgxaL6ogK/jlHjVlDLnh1SVwyo7lVNukBh0QyilPtXN2NGCnKgenucONuF0LwGp2j4ISZCyhDyXzS7qlwfuG0GTF+p6rhXjAALBPM+pPNPS/KsrJa25HHsgrRY40MSSz6sv2gM5irUK+Q=;25:mWUYgs0WCzMUpytMR7KZsxKmqr8hzO9hw/E2Nv+Kpw7H8XtdB3vpriNt4g04fLu0Zp5ZpX+DadYKE9uyabvb4rlZshFWj7qwtJrrCHrdoVaI2ITpEr6F0N6HbTAXPTU73FBjED+Dv44wG5aqm4wqIPco46ELOIHEcgQ2PDRt304D6YHve84ENIUJY3c5LLyDTBw2mmdx4tdjqMF4OBOIP3PtujOVbzRNe+UaK+p3+Yunw1BwbWXW7S7mNu65MShbbO0Nh1c01WSEbtJYtVI8QQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0301MB2004; X-Microsoft-Exchange-Diagnostics: 1;BLUPR0301MB2004;20:B+P68Yj5x1ezGG3o9/Izbu/LJsxSqULoWU0XTlbeCdoEe6BFMnKCNUhY3hzS8NVXvdmM17upvPO6Ksqp33+f+ZM1c5I4/wOiDgvPQd5k0rFQMCp3njte53tuj2KfRzLSQIv8LYgLCPoAYHBbZtDaDFgMJy/GqUgI4Kc75H0ST0lKAWvgxU9CYe/FQkwxv/KUEn2mOJSNkmhntJuce4NCysjqPxKEnhfFUPPFeXTCiZWajw3Xncz0vztYXOBYTy5L/HJ/6x9Ni3YcsTRvgt+affmmnuV2nAV07tkIU7yNMQ7nBbQUb31Jk6hzTpcA4KglmqjkZpdOVhd++Mx59gDL1WwzAUu5IZwPyorfb2qRVZQ=;4:sf4e9SDVt2FCdPBdXwnrG09jH+4YTWXwOHsgjTyH4O9Y095SykfFdeiimDAsXv7SGGvXGYAmCCy0NULMluJtB9KZD4MdIeuYhMis8oFp9rpGt0IUX55+6YiwGQJok77Z0SXgP1KG44ILl9c45ptpTDaLaSGqceiJg917wUmoOlg1Z1ltMCWR888A3OFBjl/mRHgVxqxYQhnEO8y+Dyjda0fRrbTOuTT3U3tcznOEcli7TmGDZOpXAe6TgTSD8b3Rskg+2mEPxn/SZm3as92f2xBYWrgx/Q0i0Vgl8aIopUsi6WE2XGP1Uqz0SX5jQ7Vxpv8HKxMMJ/dEwvs3FO7deEBZChmG+jJP4mcqfEeBOlQVn8U7h0GySrqYH+tdCkGD X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(10201501046)(3002001);SRVR:BLUPR0301MB2004;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0301MB2004; X-Forefront-PRVS: 07521929C1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR0301MB2004;23:DnEYIewrTMAl3pG/YrfS+6BK7PeaQQ/Ff44KVkY?= =?us-ascii?Q?Ibe80ze1CgvzWwAACmt5D76K6tGqThwEkeVni0OVsFo0FWpnpARahYhQKP4c?= =?us-ascii?Q?KBQLl6fqEG/2KhSZJDKi153HyPRZ9kikgHAcqYod4goF6IE9qwPk2aoyqTv6?= =?us-ascii?Q?+U8es3NwuC49rjPaoyo00uMW4T3p1+MYuCc4d+LENF9R5XHXRF1xmbFvF59W?= =?us-ascii?Q?IkAbZa8AtsnxAXNfgm+jM8k5QEhMUdHqd6X/h6iloOwBzne9HvWxwleqoi6a?= =?us-ascii?Q?vqfGLHGhpzDFvtvilOVZELj/RDKCVz54RMSBtSeWXKI5wJVqzKBjs108dxJH?= =?us-ascii?Q?PWEhSMekcdlGpZOMUT1zNGyUztslpUsaHYC16taC/jVQj8S6mhMNpNAS4xVM?= =?us-ascii?Q?mTRDL13RrXWvGrziVGP9Ydn0Sm06y6WD86bmvmcEsVnTDMQEL0PK+XhrucY5?= =?us-ascii?Q?4lW48AFzPO++ESX8jFR7KE+SWECGXmVEx0TpQjYaCYYYCtcAbQe079cVWbKR?= =?us-ascii?Q?oOmjmGclarGjyz8ZKSuUabi836rOSgb5gKKIVF8GkH7b2T7cXXvWiOVC2X7/?= =?us-ascii?Q?qiTO5nB66iyeO5laN1SNKFGr6eoYCdWo2w5dfOaSP4notxYCvxQ5JFD27x8i?= =?us-ascii?Q?2gdQ/opBgoxyS/L5mMeKSuvdp+1T9c5Yp0qXkCKNSbQWLepwX1H3+fvzHEJ7?= =?us-ascii?Q?A7aTcdLLMKJNY58rqsfle3SsLU2KozFRM2P0akfEXVHDS/swuA6mVWnLOF/d?= =?us-ascii?Q?E8oY+S/7cHDz1GhKfEwq/qDEQnrZqeJmZnsxu4Z7d4cXOT2XORUdN/zyaiwo?= =?us-ascii?Q?SiHLjfHSgWp3yfqztMxGiwHASNysyFUfwAIUd8LrHgBbfZI8sZZT2w/OgoIb?= =?us-ascii?Q?4HIcIhe2s0TFHbxdJsOcupuVVdeadEDn/NdnxnaB+Y+h2xkt75y9ldwZvc13?= =?us-ascii?Q?jZYLb4TRmNP+gRvevEUtj+zJslMeFuS5ix8IM9BCvP38Ftjny7L1AVsOvsiX?= =?us-ascii?Q?Mf4WKaml80B2Qwmk2TEYEws/NNQi0nsd93c6/QoJ63UUg2igmARElCQ3zD3Q?= =?us-ascii?Q?Y0evWZQLhUDjX1snBjpHz8PMZzJH+?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR0301MB2004;5:kIoreUkZVGs8Fmiq1O1kRbThoVBaDWiFPHxYJXngd8ageWhLKWtwowRKp8T8CUTrJTGd5nWepm920tDeCezCxa42K9eIuvwTe+Q6tiEYvP7/0h93SWxhFGRfPrwSes+UIqpH2xR5Rw0ZBCgSJfNfKw==;24:fGWuGlk0+e6OIwE3XJTi3ZleGgeWlrFJStmkXNbDykVtZaFnbdDaI5GHv7pSYwsfOTEhODNkbHIxD180xDktlvpyJcUgFcu5EeTjXN4zbbo=;20:8zpGdL25QHA44zUEd50a+Ke6ugs5yxty784QGHuxSEJPjiN4ZPzcJqopebsXQUhgkooVDpgHcnj2wjp0btwvsg== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2015 03:09:52.8362 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0301MB2004 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2354 Lines: 79 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 > --- > 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 -- Best Regards, Peter Chen -- 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/