Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1261487
| From | Robert Baldyga <r.baldyga@samsung.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 02/23] usb: gadget: f_sourcesink: compute req size once |
| Date | 2015-11-03 14:10 +0100 |
| Message-ID | <qqJvB-37I-29@gated-at.bofh.it> (permalink) |
| References | <qqJlU-2OU-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Compute request size once before the loop instead of computing it in each
loop iteration.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.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;
--
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/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/23] usb: gadget: composite: introduce new function API Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:00 +0100
[PATCH 21/23] usb: gadget: f_sourcesink: convert to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:00 +0100
[PATCH 09/23] usb: gadget: composite: handle function bind Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:00 +0100
[PATCH 22/23] usb: gadget: f_ecm: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:00 +0100
[PATCH 19/23] usb: gadget: configfs: add new composite API support Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:00 +0100
[PATCH 15/23] usb: gadget: composite: handle get_alt() automatically Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:00 +0100
[PATCH 01/23] usb: gadget: f_sourcesink: make ISO altset user-selectable Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:00 +0100
Re: [PATCH 01/23] usb: gadget: f_sourcesink: make ISO altset user-selectable Robert Baldyga <r.baldyga@samsung.com> - 2015-11-06 08:30 +0100
[PATCH 03/23] usb: gadget: f_sourcesink: free requests in sourcesink_disable() Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:00 +0100
Re: [PATCH 03/23] usb: gadget: f_sourcesink: free requests in sourcesink_disable() Robert Baldyga <r.baldyga@samsung.com> - 2015-11-06 10:00 +0100
Re: [PATCH 03/23] usb: gadget: f_sourcesink: free requests in sourcesink_disable() Krzysztof Opasiak <k.opasiak@samsung.com> - 2015-11-06 11:00 +0100
[PATCH 06/23] usb: gadget: composite: introduce new descriptors format Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:10 +0100
[PATCH 10/23] usb: gadget: composite: handle vendor descs Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:10 +0100
[PATCH 05/23] usb: gadget: configfs: fix error path Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:10 +0100
Re: [PATCH 05/23] usb: gadget: configfs: fix error path Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-11-03 14:50 +0100
[PATCH 11/23] usb: gadget: composite: generate old descs for compatibility Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:10 +0100
[PATCH 02/23] usb: gadget: f_sourcesink: compute req size once Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:10 +0100
[PATCH 07/23] usb: gadget: composite: add functions for descriptors handling Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:10 +0100
csiph-web