Commit 9d8bab58 authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

usb gadget stack: remove usb_ep_*_buffer(), part 1

Remove usb_ep_{alloc,free}_buffer() calls, for small dma-coherent buffers.
This patch just removes the interface and its users; later patches will
remove controller driver support.

  - This interface is invariably not implemented correctly in the
    controller drivers (e.g. using dma pools, a mechanism which
    post-dates the interface by several years).

  - At this point no gadget driver really *needs* to use it.  In
    current kernels, any driver that needs such a mechanism could
    allocate a dma pool themselves.

Removing this interface is thus a simplification and improvement.

Note that the gmidi.c driver had a bug in this area; fixed.
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent ad8c623f
...@@ -3733,19 +3733,12 @@ static void /* __init_or_exit */ fsg_unbind(struct usb_gadget *gadget) ...@@ -3733,19 +3733,12 @@ static void /* __init_or_exit */ fsg_unbind(struct usb_gadget *gadget)
} }
/* Free the data buffers */ /* Free the data buffers */
for (i = 0; i < NUM_BUFFERS; ++i) { for (i = 0; i < NUM_BUFFERS; ++i)
struct fsg_buffhd *bh = &fsg->buffhds[i]; kfree(fsg->buffhds[i].buf);
if (bh->buf)
usb_ep_free_buffer(fsg->bulk_in, bh->buf, bh->dma,
mod_data.buflen);
}
/* Free the request and buffer for endpoint 0 */ /* Free the request and buffer for endpoint 0 */
if (req) { if (req) {
if (req->buf) kfree(req->buf);
usb_ep_free_buffer(fsg->ep0, req->buf,
req->dma, EP0_BUFSIZE);
usb_ep_free_request(fsg->ep0, req); usb_ep_free_request(fsg->ep0, req);
} }
...@@ -3972,8 +3965,7 @@ static int __init fsg_bind(struct usb_gadget *gadget) ...@@ -3972,8 +3965,7 @@ static int __init fsg_bind(struct usb_gadget *gadget)
fsg->ep0req = req = usb_ep_alloc_request(fsg->ep0, GFP_KERNEL); fsg->ep0req = req = usb_ep_alloc_request(fsg->ep0, GFP_KERNEL);
if (!req) if (!req)
goto out; goto out;
req->buf = usb_ep_alloc_buffer(fsg->ep0, EP0_BUFSIZE, req->buf = kmalloc(EP0_BUFSIZE, GFP_KERNEL);
&req->dma, GFP_KERNEL);
if (!req->buf) if (!req->buf)
goto out; goto out;
req->complete = ep0_complete; req->complete = ep0_complete;
...@@ -3985,8 +3977,7 @@ static int __init fsg_bind(struct usb_gadget *gadget) ...@@ -3985,8 +3977,7 @@ static int __init fsg_bind(struct usb_gadget *gadget)
/* Allocate for the bulk-in endpoint. We assume that /* Allocate for the bulk-in endpoint. We assume that
* the buffer will also work with the bulk-out (and * the buffer will also work with the bulk-out (and
* interrupt-in) endpoint. */ * interrupt-in) endpoint. */
bh->buf = usb_ep_alloc_buffer(fsg->bulk_in, mod_data.buflen, bh->buf = kmalloc(mod_data.buflen, GFP_KERNEL);
&bh->dma, GFP_KERNEL);
if (!bh->buf) if (!bh->buf)
goto out; goto out;
bh->next = bh + 1; bh->next = bh + 1;
......
...@@ -1248,17 +1248,11 @@ autoconf_fail: ...@@ -1248,17 +1248,11 @@ autoconf_fail:
tasklet_init(&dev->tasklet, gmidi_in_tasklet, (unsigned long)dev); tasklet_init(&dev->tasklet, gmidi_in_tasklet, (unsigned long)dev);
/* preallocate control response and buffer */ /* preallocate control response and buffer */
dev->req = usb_ep_alloc_request(gadget->ep0, GFP_KERNEL); dev->req = alloc_ep_req(gadget->ep0, USB_BUFSIZ);
if (!dev->req) { if (!dev->req) {
err = -ENOMEM; err = -ENOMEM;
goto fail; goto fail;
} }
dev->req->buf = usb_ep_alloc_buffer(gadget->ep0, USB_BUFSIZ,
&dev->req->dma, GFP_KERNEL);
if (!dev->req->buf) {
err = -ENOMEM;
goto fail;
}
dev->req->complete = gmidi_setup_complete; dev->req->complete = gmidi_setup_complete;
......
...@@ -923,7 +923,7 @@ static void clean_req (struct usb_ep *ep, struct usb_request *req) ...@@ -923,7 +923,7 @@ static void clean_req (struct usb_ep *ep, struct usb_request *req)
struct dev_data *dev = ep->driver_data; struct dev_data *dev = ep->driver_data;
if (req->buf != dev->rbuf) { if (req->buf != dev->rbuf) {
usb_ep_free_buffer (ep, req->buf, req->dma, req->length); kfree(req->buf);
req->buf = dev->rbuf; req->buf = dev->rbuf;
req->dma = DMA_ADDR_INVALID; req->dma = DMA_ADDR_INVALID;
} }
...@@ -963,7 +963,7 @@ static int setup_req (struct usb_ep *ep, struct usb_request *req, u16 len) ...@@ -963,7 +963,7 @@ static int setup_req (struct usb_ep *ep, struct usb_request *req, u16 len)
return -EBUSY; return -EBUSY;
} }
if (len > sizeof (dev->rbuf)) if (len > sizeof (dev->rbuf))
req->buf = usb_ep_alloc_buffer (ep, len, &req->dma, GFP_ATOMIC); req->buf = kmalloc(len, GFP_ATOMIC);
if (req->buf == 0) { if (req->buf == 0) {
req->buf = dev->rbuf; req->buf = dev->rbuf;
return -ENOMEM; return -ENOMEM;
......
...@@ -481,8 +481,7 @@ alloc_ep_req (struct usb_ep *ep, unsigned length) ...@@ -481,8 +481,7 @@ alloc_ep_req (struct usb_ep *ep, unsigned length)
req = usb_ep_alloc_request (ep, GFP_ATOMIC); req = usb_ep_alloc_request (ep, GFP_ATOMIC);
if (req) { if (req) {
req->length = length; req->length = length;
req->buf = usb_ep_alloc_buffer (ep, length, req->buf = kmalloc(length, GFP_ATOMIC);
&req->dma, GFP_ATOMIC);
if (!req->buf) { if (!req->buf) {
usb_ep_free_request (ep, req); usb_ep_free_request (ep, req);
req = NULL; req = NULL;
...@@ -493,8 +492,7 @@ alloc_ep_req (struct usb_ep *ep, unsigned length) ...@@ -493,8 +492,7 @@ alloc_ep_req (struct usb_ep *ep, unsigned length)
static void free_ep_req (struct usb_ep *ep, struct usb_request *req) static void free_ep_req (struct usb_ep *ep, struct usb_request *req)
{ {
if (req->buf) kfree(req->buf);
usb_ep_free_buffer (ep, req->buf, req->dma, req->length);
usb_ep_free_request (ep, req); usb_ep_free_request (ep, req);
} }
...@@ -1199,8 +1197,7 @@ autoconf_fail: ...@@ -1199,8 +1197,7 @@ autoconf_fail:
dev->req = usb_ep_alloc_request (gadget->ep0, GFP_KERNEL); dev->req = usb_ep_alloc_request (gadget->ep0, GFP_KERNEL);
if (!dev->req) if (!dev->req)
goto enomem; goto enomem;
dev->req->buf = usb_ep_alloc_buffer (gadget->ep0, USB_BUFSIZ, dev->req->buf = kmalloc(USB_BUFSIZ, GFP_KERNEL);
&dev->req->dma, GFP_KERNEL);
if (!dev->req->buf) if (!dev->req->buf)
goto enomem; goto enomem;
......
...@@ -234,47 +234,6 @@ usb_ep_free_request (struct usb_ep *ep, struct usb_request *req) ...@@ -234,47 +234,6 @@ usb_ep_free_request (struct usb_ep *ep, struct usb_request *req)
ep->ops->free_request (ep, req); ep->ops->free_request (ep, req);
} }
/**
* usb_ep_alloc_buffer - allocate an I/O buffer
* @ep:the endpoint associated with the buffer
* @len:length of the desired buffer
* @dma:pointer to the buffer's DMA address; must be valid
* @gfp_flags:GFP_* flags to use
*
* Returns a new buffer, or null if one could not be allocated.
* The buffer is suitably aligned for dma, if that endpoint uses DMA,
* and the caller won't have to care about dma-inconsistency
* or any hidden "bounce buffer" mechanism. No additional per-request
* DMA mapping will be required for such buffers.
* Free it later with usb_ep_free_buffer().
*
* You don't need to use this call to allocate I/O buffers unless you
* want to make sure drivers don't incur costs for such "bounce buffer"
* copies or per-request DMA mappings.
*/
static inline void *
usb_ep_alloc_buffer (struct usb_ep *ep, unsigned len, dma_addr_t *dma,
gfp_t gfp_flags)
{
return ep->ops->alloc_buffer (ep, len, dma, gfp_flags);
}
/**
* usb_ep_free_buffer - frees an i/o buffer
* @ep:the endpoint associated with the buffer
* @buf:CPU view address of the buffer
* @dma:the buffer's DMA address
* @len:length of the buffer
*
* reverses the effect of usb_ep_alloc_buffer().
* caller guarantees the buffer will no longer be accessed
*/
static inline void
usb_ep_free_buffer (struct usb_ep *ep, void *buf, dma_addr_t dma, unsigned len)
{
ep->ops->free_buffer (ep, buf, dma, len);
}
/** /**
* usb_ep_queue - queues (submits) an I/O request to an endpoint. * usb_ep_queue - queues (submits) an I/O request to an endpoint.
* @ep:the endpoint associated with the request * @ep:the endpoint associated with the request
......
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