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

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: default avatarFelipe F. Tonello <eu@felipetonello.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent 06281d46
...@@ -365,7 +365,7 @@ static int f_hidg_open(struct inode *inode, struct file *fd) ...@@ -365,7 +365,7 @@ static int f_hidg_open(struct inode *inode, struct file *fd)
static inline struct usb_request *hidg_alloc_ep_req(struct usb_ep *ep, static inline struct usb_request *hidg_alloc_ep_req(struct usb_ep *ep,
unsigned length) unsigned length)
{ {
return alloc_ep_req(ep, length, length); return alloc_ep_req(ep, length);
} }
static void hidg_set_report_complete(struct usb_ep *ep, struct usb_request *req) static void hidg_set_report_complete(struct usb_ep *ep, struct usb_request *req)
......
...@@ -308,9 +308,7 @@ static void disable_loopback(struct f_loopback *loop) ...@@ -308,9 +308,7 @@ static void disable_loopback(struct f_loopback *loop)
static inline struct usb_request *lb_alloc_ep_req(struct usb_ep *ep, int len) static inline struct usb_request *lb_alloc_ep_req(struct usb_ep *ep, int len)
{ {
struct f_loopback *loop = ep->driver_data; return alloc_ep_req(ep, len);
return alloc_ep_req(ep, len, loop->buflen);
} }
static int alloc_requests(struct usb_composite_dev *cdev, static int alloc_requests(struct usb_composite_dev *cdev,
...@@ -333,7 +331,7 @@ static int alloc_requests(struct usb_composite_dev *cdev, ...@@ -333,7 +331,7 @@ static int alloc_requests(struct usb_composite_dev *cdev,
if (!in_req) if (!in_req)
goto fail; goto fail;
out_req = lb_alloc_ep_req(loop->out_ep, 0); out_req = lb_alloc_ep_req(loop->out_ep, loop->buflen);
if (!out_req) if (!out_req)
goto fail_in; goto fail_in;
......
...@@ -211,7 +211,7 @@ static struct usb_gadget_strings *midi_strings[] = { ...@@ -211,7 +211,7 @@ static struct usb_gadget_strings *midi_strings[] = {
static inline struct usb_request *midi_alloc_ep_req(struct usb_ep *ep, static inline struct usb_request *midi_alloc_ep_req(struct usb_ep *ep,
unsigned length) unsigned length)
{ {
return alloc_ep_req(ep, length, length); return alloc_ep_req(ep, length);
} }
static const uint8_t f_midi_cin_length[] = { static const uint8_t f_midi_cin_length[] = {
......
...@@ -293,9 +293,7 @@ static struct usb_gadget_strings *sourcesink_strings[] = { ...@@ -293,9 +293,7 @@ static struct usb_gadget_strings *sourcesink_strings[] = {
static inline struct usb_request *ss_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 f_sourcesink *ss = ep->driver_data; return alloc_ep_req(ep, len);
return alloc_ep_req(ep, len, ss->buflen);
} }
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)
...@@ -606,7 +604,7 @@ static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in, ...@@ -606,7 +604,7 @@ static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in,
} else { } else {
ep = is_in ? ss->in_ep : ss->out_ep; ep = is_in ? ss->in_ep : ss->out_ep;
qlen = ss->bulk_qlen; qlen = ss->bulk_qlen;
size = 0; size = ss->buflen;
} }
for (i = 0; i < qlen; i++) { for (i = 0; i < qlen; i++) {
......
...@@ -14,15 +14,14 @@ ...@@ -14,15 +14,14 @@
#include "u_f.h" #include "u_f.h"
#include <linux/usb/ch9.h> #include <linux/usb/ch9.h>
struct usb_request *alloc_ep_req(struct usb_ep *ep, size_t len, int default_len) struct usb_request *alloc_ep_req(struct usb_ep *ep, size_t len)
{ {
struct usb_request *req; struct usb_request *req;
req = usb_ep_alloc_request(ep, GFP_ATOMIC); req = usb_ep_alloc_request(ep, GFP_ATOMIC);
if (req) { if (req) {
req->length = len ?: default_len; req->length = usb_endpoint_dir_out(ep->desc) ?
if (usb_endpoint_dir_out(ep->desc)) usb_ep_align(ep, len) : len;
req->length = usb_ep_align(ep, req->length);
req->buf = kmalloc(req->length, GFP_ATOMIC); req->buf = kmalloc(req->length, GFP_ATOMIC);
if (!req->buf) { if (!req->buf) {
usb_ep_free_request(ep, req); usb_ep_free_request(ep, req);
......
...@@ -53,14 +53,13 @@ struct usb_request; ...@@ -53,14 +53,13 @@ struct usb_request;
* *
* @ep: the endpoint to allocate a usb_request * @ep: the endpoint to allocate a usb_request
* @len: usb_requests's buffer suggested size * @len: usb_requests's buffer suggested size
* @default_len: used if @len is not provided, ie, is 0
* *
* In case @ep direction is OUT, the @len will be aligned to ep's * In case @ep direction is OUT, the @len will be aligned to ep's
* wMaxPacketSize. In order to avoid memory leaks or drops, *always* use * wMaxPacketSize. In order to avoid memory leaks or drops, *always* use
* usb_requests's length (req->length) to refer to the allocated buffer size. * usb_requests's length (req->length) to refer to the allocated buffer size.
* Requests allocated via alloc_ep_req() *must* be freed by free_ep_req(). * Requests allocated via alloc_ep_req() *must* be freed by free_ep_req().
*/ */
struct usb_request *alloc_ep_req(struct usb_ep *ep, size_t len, int default_len); struct usb_request *alloc_ep_req(struct usb_ep *ep, size_t len);
/* Frees a usb_request previously allocated by alloc_ep_req() */ /* Frees a usb_request previously allocated by alloc_ep_req() */
static inline void free_ep_req(struct usb_ep *ep, struct usb_request *req) static inline void free_ep_req(struct usb_ep *ep, struct usb_request *req)
......
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