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

usb: gadget: remove useless parameter in alloc_ep_req()

The default_length parameter of alloc_ep_req was not really necessary
and gadget drivers would almost always create an inline function to pass
the same value to len and default_len.

This patch removes that parameter and updates all calls to alloc_ep_req() to
use the new API.

Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

authored by

Felipe F. Tonello and committed by
Felipe Balbi
aadbe812 06281d46

+10 -16
+1 -1
drivers/usb/gadget/function/f_hid.c
··· 365 365 static inline struct usb_request *hidg_alloc_ep_req(struct usb_ep *ep, 366 366 unsigned length) 367 367 { 368 - return alloc_ep_req(ep, length, length); 368 + return alloc_ep_req(ep, length); 369 369 } 370 370 371 371 static void hidg_set_report_complete(struct usb_ep *ep, struct usb_request *req)
+2 -4
drivers/usb/gadget/function/f_loopback.c
··· 308 308 309 309 static inline struct usb_request *lb_alloc_ep_req(struct usb_ep *ep, int len) 310 310 { 311 - struct f_loopback *loop = ep->driver_data; 312 - 313 - return alloc_ep_req(ep, len, loop->buflen); 311 + return alloc_ep_req(ep, len); 314 312 } 315 313 316 314 static int alloc_requests(struct usb_composite_dev *cdev, ··· 331 333 if (!in_req) 332 334 goto fail; 333 335 334 - out_req = lb_alloc_ep_req(loop->out_ep, 0); 336 + out_req = lb_alloc_ep_req(loop->out_ep, loop->buflen); 335 337 if (!out_req) 336 338 goto fail_in; 337 339
+1 -1
drivers/usb/gadget/function/f_midi.c
··· 211 211 static inline struct usb_request *midi_alloc_ep_req(struct usb_ep *ep, 212 212 unsigned length) 213 213 { 214 - return alloc_ep_req(ep, length, length); 214 + return alloc_ep_req(ep, length); 215 215 } 216 216 217 217 static const uint8_t f_midi_cin_length[] = {
+2 -4
drivers/usb/gadget/function/f_sourcesink.c
··· 293 293 294 294 static inline struct usb_request *ss_alloc_ep_req(struct usb_ep *ep, int len) 295 295 { 296 - struct f_sourcesink *ss = ep->driver_data; 297 - 298 - return alloc_ep_req(ep, len, ss->buflen); 296 + return alloc_ep_req(ep, len); 299 297 } 300 298 301 299 static void disable_ep(struct usb_composite_dev *cdev, struct usb_ep *ep) ··· 604 606 } else { 605 607 ep = is_in ? ss->in_ep : ss->out_ep; 606 608 qlen = ss->bulk_qlen; 607 - size = 0; 609 + size = ss->buflen; 608 610 } 609 611 610 612 for (i = 0; i < qlen; i++) {
+3 -4
drivers/usb/gadget/u_f.c
··· 14 14 #include "u_f.h" 15 15 #include <linux/usb/ch9.h> 16 16 17 - struct usb_request *alloc_ep_req(struct usb_ep *ep, size_t len, int default_len) 17 + struct usb_request *alloc_ep_req(struct usb_ep *ep, size_t len) 18 18 { 19 19 struct usb_request *req; 20 20 21 21 req = usb_ep_alloc_request(ep, GFP_ATOMIC); 22 22 if (req) { 23 - req->length = len ?: default_len; 24 - if (usb_endpoint_dir_out(ep->desc)) 25 - req->length = usb_ep_align(ep, req->length); 23 + req->length = usb_endpoint_dir_out(ep->desc) ? 24 + usb_ep_align(ep, len) : len; 26 25 req->buf = kmalloc(req->length, GFP_ATOMIC); 27 26 if (!req->buf) { 28 27 usb_ep_free_request(ep, req);
+1 -2
drivers/usb/gadget/u_f.h
··· 53 53 * 54 54 * @ep: the endpoint to allocate a usb_request 55 55 * @len: usb_requests's buffer suggested size 56 - * @default_len: used if @len is not provided, ie, is 0 57 56 * 58 57 * In case @ep direction is OUT, the @len will be aligned to ep's 59 58 * wMaxPacketSize. In order to avoid memory leaks or drops, *always* use 60 59 * usb_requests's length (req->length) to refer to the allocated buffer size. 61 60 * Requests allocated via alloc_ep_req() *must* be freed by free_ep_req(). 62 61 */ 63 - struct usb_request *alloc_ep_req(struct usb_ep *ep, size_t len, int default_len); 62 + struct usb_request *alloc_ep_req(struct usb_ep *ep, size_t len); 64 63 65 64 /* Frees a usb_request previously allocated by alloc_ep_req() */ 66 65 static inline void free_ep_req(struct usb_ep *ep, struct usb_request *req)