diff options
author | Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 2013-11-07 08:41:26 +0100 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-11-26 13:41:32 -0600 |
commit | 1efd54eab2b60c68c2ce75ea635306cef847d751 (patch) | |
tree | b810315964acc35866cf4cda9c1032a6c71e83bf /drivers/usb/gadget/f_sourcesink.c | |
parent | a01091e5ce866562ea2638a80f2241d8d6bde164 (diff) | |
download | op-kernel-dev-1efd54eab2b60c68c2ce75ea635306cef847d751.zip op-kernel-dev-1efd54eab2b60c68c2ce75ea635306cef847d751.tar.gz |
usb: gadget: factor out alloc_ep_req
alloc_ep_req() is a function repeated in several modules.
Make a common implementation and use it.
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/f_sourcesink.c')
-rw-r--r-- | drivers/usb/gadget/f_sourcesink.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c index a889585..c5ad4a1 100644 --- a/drivers/usb/gadget/f_sourcesink.c +++ b/drivers/usb/gadget/f_sourcesink.c @@ -21,6 +21,7 @@ #include "g_zero.h" #include "gadget_chips.h" +#include "u_f.h" /* * SOURCE/SINK FUNCTION ... a primary testing vehicle for USB peripheral @@ -301,23 +302,9 @@ static struct usb_gadget_strings *sourcesink_strings[] = { /*-------------------------------------------------------------------------*/ -struct usb_request *alloc_ep_req(struct usb_ep *ep, int len) +static inline struct usb_request *ss_alloc_ep_req(struct usb_ep *ep, int len) { - struct usb_request *req; - - req = usb_ep_alloc_request(ep, GFP_ATOMIC); - if (req) { - if (len) - req->length = len; - else - req->length = buflen; - req->buf = kmalloc(req->length, GFP_ATOMIC); - if (!req->buf) { - usb_ep_free_request(ep, req); - req = NULL; - } - } - return req; + return alloc_ep_req(ep, len, buflen); } void free_ep_req(struct usb_ep *ep, struct usb_request *req) @@ -628,10 +615,10 @@ static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in, break; } ep = is_in ? ss->iso_in_ep : ss->iso_out_ep; - req = alloc_ep_req(ep, size); + req = ss_alloc_ep_req(ep, size); } else { ep = is_in ? ss->in_ep : ss->out_ep; - req = alloc_ep_req(ep, 0); + req = ss_alloc_ep_req(ep, 0); } if (!req) |