Compute request size once before the loop instead of computing it in each
loop iteration.

Signed-off-by: Robert Baldyga <r.bald...@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-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to