summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/u_f.h
diff options
context:
space:
mode:
authorFelipe F. Tonello <eu@felipetonello.com>2015-11-10 17:52:05 +0000
committerFelipe Balbi <balbi@ti.com>2015-12-15 09:12:41 -0600
commit079fe5a6da616891cca1a26e803e1df2a87e9ae5 (patch)
tree8de7bad5ce23cdc9837c8c697b608bc8533c909f /drivers/usb/gadget/u_f.h
parentbc1d3cdc9c3cbbd9040da8c53237e177c38048b0 (diff)
downloadlinux-079fe5a6da616891cca1a26e803e1df2a87e9ae5.tar.gz
linux-079fe5a6da616891cca1a26e803e1df2a87e9ae5.tar.bz2
linux-079fe5a6da616891cca1a26e803e1df2a87e9ae5.zip
usb: gadget: define free_ep_req as universal function
This function is shared between gadget functions, so this avoid unnecessary duplicated code and potentially avoid memory leaks. Reviewed-by: Robert Baldyga <r.baldyga@samsung.com> Signed-off-by: Felipe F. Tonello <eu@felipetonello.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/u_f.h')
-rw-r--r--drivers/usb/gadget/u_f.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/usb/gadget/u_f.h b/drivers/usb/gadget/u_f.h
index 1d5f0eb68552..4247cc098a89 100644
--- a/drivers/usb/gadget/u_f.h
+++ b/drivers/usb/gadget/u_f.h
@@ -16,6 +16,8 @@
#ifndef __U_F_H__
#define __U_F_H__
+#include <linux/usb/gadget.h>
+
/* Variable Length Array Macros **********************************************/
#define vla_group(groupname) size_t groupname##__next = 0
#define vla_group_size(groupname) groupname##__next
@@ -45,8 +47,12 @@
struct usb_ep;
struct usb_request;
+/* Requests allocated via alloc_ep_req() must be freed by free_ep_req(). */
struct usb_request *alloc_ep_req(struct usb_ep *ep, int len, int default_len);
+static inline void free_ep_req(struct usb_ep *ep, struct usb_request *req)
+{
+ kfree(req->buf);
+ usb_ep_free_request(ep, req);
+}
#endif /* __U_F_H__ */
-
-