aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/net2280.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-12 19:46:58 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-12 19:46:58 -0400
commit9374430a52dfae5c013b88f7f030c04a6774d410 (patch)
treece1ee8eee4e79fbb9486e810278d1092afc74a44 /drivers/usb/gadget/net2280.c
parent66f49739fe1591197364f2dad1b67b975e8f5e85 (diff)
parent13f9966b3ba5b45f47f2ea0eb0a90afceedfbb1f (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/usb-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/usb-2.6: (149 commits) USB: ohci-pnx4008: Remove unnecessary cast of return value of kzalloc USB: additions to the quirk list usb-storage: implement autosuspend USB: cdc-acm: add new device id to option driver USB: goku_udc trivial cleanups USB: usb gadget stack can now -DDEBUG with Kconfig usb gadget stack: remove usb_ep_*_buffer(), part 2 usb gadget stack: remove usb_ep_*_buffer(), part 1 USB: pxa2xx_udc -- cleanups, mostly removing dma hooks USB: pxa2xx_udc: use generic gpio layer USB: quirk for samsung printer USB: usb/dma doc updates USB: drivers/usb/storage/unusual_devs.h whitespace cleanup USB: remove Makefile reference to obsolete OHCI_AT91 USB: io_*: remove bogus termios no change checks USB: mos7720: remove bogus no termios change check USB: visor and whiteheat: remove bogus termios change checks USB: pl2303: remove bogus checks and fix speed support to use tty_get_baud_rate() USB: mos7840.c: turn this into a serial driver USB: make the usb_device numa_node get assigned from controller ...
Diffstat (limited to 'drivers/usb/gadget/net2280.c')
-rw-r--r--drivers/usb/gadget/net2280.c97
1 files changed, 0 insertions, 97 deletions
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 00fda334dc72..c3d364ecd4f8 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -450,100 +450,6 @@ net2280_free_request (struct usb_ep *_ep, struct usb_request *_req)
450 450
451/*-------------------------------------------------------------------------*/ 451/*-------------------------------------------------------------------------*/
452 452
453/*
454 * dma-coherent memory allocation (for dma-capable endpoints)
455 *
456 * NOTE: the dma_*_coherent() API calls suck. Most implementations are
457 * (a) page-oriented, so small buffers lose big; and (b) asymmetric with
458 * respect to calls with irqs disabled: alloc is safe, free is not.
459 * We currently work around (b), but not (a).
460 */
461
462static void *
463net2280_alloc_buffer (
464 struct usb_ep *_ep,
465 unsigned bytes,
466 dma_addr_t *dma,
467 gfp_t gfp_flags
468)
469{
470 void *retval;
471 struct net2280_ep *ep;
472
473 ep = container_of (_ep, struct net2280_ep, ep);
474 if (!_ep)
475 return NULL;
476 *dma = DMA_ADDR_INVALID;
477
478 if (ep->dma)
479 retval = dma_alloc_coherent(&ep->dev->pdev->dev,
480 bytes, dma, gfp_flags);
481 else
482 retval = kmalloc(bytes, gfp_flags);
483 return retval;
484}
485
486static DEFINE_SPINLOCK(buflock);
487static LIST_HEAD(buffers);
488
489struct free_record {
490 struct list_head list;
491 struct device *dev;
492 unsigned bytes;
493 dma_addr_t dma;
494};
495
496static void do_free(unsigned long ignored)
497{
498 spin_lock_irq(&buflock);
499 while (!list_empty(&buffers)) {
500 struct free_record *buf;
501
502 buf = list_entry(buffers.next, struct free_record, list);
503 list_del(&buf->list);
504 spin_unlock_irq(&buflock);
505
506 dma_free_coherent(buf->dev, buf->bytes, buf, buf->dma);
507
508 spin_lock_irq(&buflock);
509 }
510 spin_unlock_irq(&buflock);
511}
512
513static DECLARE_TASKLET(deferred_free, do_free, 0);
514
515static void
516net2280_free_buffer (
517 struct usb_ep *_ep,
518 void *address,
519 dma_addr_t dma,
520 unsigned bytes
521) {
522 /* free memory into the right allocator */
523 if (dma != DMA_ADDR_INVALID) {
524 struct net2280_ep *ep;
525 struct free_record *buf = address;
526 unsigned long flags;
527
528 ep = container_of(_ep, struct net2280_ep, ep);
529 if (!_ep)
530 return;
531
532 ep = container_of (_ep, struct net2280_ep, ep);
533 buf->dev = &ep->dev->pdev->dev;
534 buf->bytes = bytes;
535 buf->dma = dma;
536
537 spin_lock_irqsave(&buflock, flags);
538 list_add_tail(&buf->list, &buffers);
539 tasklet_schedule(&deferred_free);
540 spin_unlock_irqrestore(&buflock, flags);
541 } else
542 kfree (address);
543}
544
545/*-------------------------------------------------------------------------*/
546
547/* load a packet into the fifo we use for usb IN transfers. 453/* load a packet into the fifo we use for usb IN transfers.
548 * works for all endpoints. 454 * works for all endpoints.
549 * 455 *
@@ -1392,9 +1298,6 @@ static const struct usb_ep_ops net2280_ep_ops = {
1392 .alloc_request = net2280_alloc_request, 1298 .alloc_request = net2280_alloc_request,
1393 .free_request = net2280_free_request, 1299 .free_request = net2280_free_request,
1394 1300
1395 .alloc_buffer = net2280_alloc_buffer,
1396 .free_buffer = net2280_free_buffer,
1397
1398 .queue = net2280_queue, 1301 .queue = net2280_queue,
1399 .dequeue = net2280_dequeue, 1302 .dequeue = net2280_dequeue,
1400 1303