Commit 079fe5a6 authored by Felipe F. Tonello's avatar Felipe F. Tonello Committed by Felipe Balbi

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: default avatarRobert Baldyga <r.baldyga@samsung.com>
Signed-off-by: default avatarFelipe F. Tonello <eu@felipetonello.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent bc1d3cdc
...@@ -201,12 +201,6 @@ static inline struct usb_request *midi_alloc_ep_req(struct usb_ep *ep, ...@@ -201,12 +201,6 @@ static inline struct usb_request *midi_alloc_ep_req(struct usb_ep *ep,
return alloc_ep_req(ep, length, length); return alloc_ep_req(ep, length, length);
} }
static void free_ep_req(struct usb_ep *ep, struct usb_request *req)
{
kfree(req->buf);
usb_ep_free_request(ep, req);
}
static const uint8_t f_midi_cin_length[] = { static const uint8_t f_midi_cin_length[] = {
0, 0, 2, 3, 3, 1, 2, 3, 3, 3, 3, 3, 2, 2, 3, 1 0, 0, 2, 3, 3, 1, 2, 3, 3, 3, 3, 3, 2, 2, 3, 1
}; };
......
...@@ -298,12 +298,6 @@ static inline struct usb_request *ss_alloc_ep_req(struct usb_ep *ep, int len) ...@@ -298,12 +298,6 @@ static inline struct usb_request *ss_alloc_ep_req(struct usb_ep *ep, int len)
return alloc_ep_req(ep, len, ss->buflen); return alloc_ep_req(ep, len, ss->buflen);
} }
void free_ep_req(struct usb_ep *ep, struct usb_request *req)
{
kfree(req->buf);
usb_ep_free_request(ep, req);
}
static void disable_ep(struct usb_composite_dev *cdev, struct usb_ep *ep) static void disable_ep(struct usb_composite_dev *cdev, struct usb_ep *ep)
{ {
int value; int value;
......
...@@ -65,7 +65,6 @@ void lb_modexit(void); ...@@ -65,7 +65,6 @@ void lb_modexit(void);
int lb_modinit(void); int lb_modinit(void);
/* common utilities */ /* common utilities */
void free_ep_req(struct usb_ep *ep, struct usb_request *req);
void disable_endpoints(struct usb_composite_dev *cdev, void disable_endpoints(struct usb_composite_dev *cdev,
struct usb_ep *in, struct usb_ep *out, struct usb_ep *in, struct usb_ep *out,
struct usb_ep *iso_in, struct usb_ep *iso_out); struct usb_ep *iso_in, struct usb_ep *iso_out);
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#include <linux/usb/gadget.h>
#include "u_f.h" #include "u_f.h"
struct usb_request *alloc_ep_req(struct usb_ep *ep, int len, int default_len) struct usb_request *alloc_ep_req(struct usb_ep *ep, int len, int default_len)
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#ifndef __U_F_H__ #ifndef __U_F_H__
#define __U_F_H__ #define __U_F_H__
#include <linux/usb/gadget.h>
/* Variable Length Array Macros **********************************************/ /* Variable Length Array Macros **********************************************/
#define vla_group(groupname) size_t groupname##__next = 0 #define vla_group(groupname) size_t groupname##__next = 0
#define vla_group_size(groupname) groupname##__next #define vla_group_size(groupname) groupname##__next
...@@ -45,8 +47,12 @@ ...@@ -45,8 +47,12 @@
struct usb_ep; struct usb_ep;
struct usb_request; 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); 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__ */ #endif /* __U_F_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment