Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Felipe F. Tonello and committed by
Felipe Balbi
079fe5a6 bc1d3cdc

+8 -16
-6
drivers/usb/gadget/function/f_midi.c
··· 201 201 return alloc_ep_req(ep, length, length); 202 202 } 203 203 204 - static void free_ep_req(struct usb_ep *ep, struct usb_request *req) 205 - { 206 - kfree(req->buf); 207 - usb_ep_free_request(ep, req); 208 - } 209 - 210 204 static const uint8_t f_midi_cin_length[] = { 211 205 0, 0, 2, 3, 3, 1, 2, 3, 3, 3, 3, 3, 2, 2, 3, 1 212 206 };
-6
drivers/usb/gadget/function/f_sourcesink.c
··· 298 298 return alloc_ep_req(ep, len, ss->buflen); 299 299 } 300 300 301 - void free_ep_req(struct usb_ep *ep, struct usb_request *req) 302 - { 303 - kfree(req->buf); 304 - usb_ep_free_request(ep, req); 305 - } 306 - 307 301 static void disable_ep(struct usb_composite_dev *cdev, struct usb_ep *ep) 308 302 { 309 303 int value;
-1
drivers/usb/gadget/function/g_zero.h
··· 65 65 int lb_modinit(void); 66 66 67 67 /* common utilities */ 68 - void free_ep_req(struct usb_ep *ep, struct usb_request *req); 69 68 void disable_endpoints(struct usb_composite_dev *cdev, 70 69 struct usb_ep *in, struct usb_ep *out, 71 70 struct usb_ep *iso_in, struct usb_ep *iso_out);
-1
drivers/usb/gadget/u_f.c
··· 11 11 * published by the Free Software Foundation. 12 12 */ 13 13 14 - #include <linux/usb/gadget.h> 15 14 #include "u_f.h" 16 15 17 16 struct usb_request *alloc_ep_req(struct usb_ep *ep, int len, int default_len)
+8 -2
drivers/usb/gadget/u_f.h
··· 16 16 #ifndef __U_F_H__ 17 17 #define __U_F_H__ 18 18 19 + #include <linux/usb/gadget.h> 20 + 19 21 /* Variable Length Array Macros **********************************************/ 20 22 #define vla_group(groupname) size_t groupname##__next = 0 21 23 #define vla_group_size(groupname) groupname##__next ··· 47 45 struct usb_ep; 48 46 struct usb_request; 49 47 48 + /* Requests allocated via alloc_ep_req() must be freed by free_ep_req(). */ 50 49 struct usb_request *alloc_ep_req(struct usb_ep *ep, int len, int default_len); 50 + static inline void free_ep_req(struct usb_ep *ep, struct usb_request *req) 51 + { 52 + kfree(req->buf); 53 + usb_ep_free_request(ep, req); 54 + } 51 55 52 56 #endif /* __U_F_H__ */ 53 - 54 -