Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
[firefly-linux-kernel-4.4.55.git] / drivers / usb / gadget / net2280.c
index 00fda334dc72e5c3724120b19e267bb07863e94e..e01862300169772d714a6ab24a4db9938825fd9d 100644 (file)
@@ -62,7 +62,7 @@
 #include <linux/moduleparam.h>
 #include <linux/device.h>
 #include <linux/usb/ch9.h>
-#include <linux/usb_gadget.h>
+#include <linux/usb/gadget.h>
 
 #include <asm/byteorder.h>
 #include <asm/io.h>
@@ -450,100 +450,6 @@ net2280_free_request (struct usb_ep *_ep, struct usb_request *_req)
 
 /*-------------------------------------------------------------------------*/
 
-/*
- * dma-coherent memory allocation (for dma-capable endpoints)
- *
- * NOTE: the dma_*_coherent() API calls suck.  Most implementations are
- * (a) page-oriented, so small buffers lose big; and (b) asymmetric with
- * respect to calls with irqs disabled:  alloc is safe, free is not.
- * We currently work around (b), but not (a).
- */
-
-static void *
-net2280_alloc_buffer (
-       struct usb_ep           *_ep,
-       unsigned                bytes,
-       dma_addr_t              *dma,
-       gfp_t                   gfp_flags
-)
-{
-       void                    *retval;
-       struct net2280_ep       *ep;
-
-       ep = container_of (_ep, struct net2280_ep, ep);
-       if (!_ep)
-               return NULL;
-       *dma = DMA_ADDR_INVALID;
-
-       if (ep->dma)
-               retval = dma_alloc_coherent(&ep->dev->pdev->dev,
-                               bytes, dma, gfp_flags);
-       else
-               retval = kmalloc(bytes, gfp_flags);
-       return retval;
-}
-
-static DEFINE_SPINLOCK(buflock);
-static LIST_HEAD(buffers);
-
-struct free_record {
-       struct list_head        list;
-       struct device           *dev;
-       unsigned                bytes;
-       dma_addr_t              dma;
-};
-
-static void do_free(unsigned long ignored)
-{
-       spin_lock_irq(&buflock);
-       while (!list_empty(&buffers)) {
-               struct free_record      *buf;
-
-               buf = list_entry(buffers.next, struct free_record, list);
-               list_del(&buf->list);
-               spin_unlock_irq(&buflock);
-
-               dma_free_coherent(buf->dev, buf->bytes, buf, buf->dma);
-
-               spin_lock_irq(&buflock);
-       }
-       spin_unlock_irq(&buflock);
-}
-
-static DECLARE_TASKLET(deferred_free, do_free, 0);
-
-static void
-net2280_free_buffer (
-       struct usb_ep *_ep,
-       void *address,
-       dma_addr_t dma,
-       unsigned bytes
-) {
-       /* free memory into the right allocator */
-       if (dma != DMA_ADDR_INVALID) {
-               struct net2280_ep       *ep;
-               struct free_record      *buf = address;
-               unsigned long           flags;
-
-               ep = container_of(_ep, struct net2280_ep, ep);
-               if (!_ep)
-                       return;
-
-               ep = container_of (_ep, struct net2280_ep, ep);
-               buf->dev = &ep->dev->pdev->dev;
-               buf->bytes = bytes;
-               buf->dma = dma;
-
-               spin_lock_irqsave(&buflock, flags);
-               list_add_tail(&buf->list, &buffers);
-               tasklet_schedule(&deferred_free);
-               spin_unlock_irqrestore(&buflock, flags);
-       } else
-               kfree (address);
-}
-
-/*-------------------------------------------------------------------------*/
-
 /* load a packet into the fifo we use for usb IN transfers.
  * works for all endpoints.
  *
@@ -1392,9 +1298,6 @@ static const struct usb_ep_ops net2280_ep_ops = {
        .alloc_request  = net2280_alloc_request,
        .free_request   = net2280_free_request,
 
-       .alloc_buffer   = net2280_alloc_buffer,
-       .free_buffer    = net2280_free_buffer,
-
        .queue          = net2280_queue,
        .dequeue        = net2280_dequeue,
 
@@ -1515,8 +1418,8 @@ show_function (struct device *_dev, struct device_attribute *attr, char *buf)
 }
 static DEVICE_ATTR (function, S_IRUGO, show_function, NULL);
 
-static ssize_t
-show_registers (struct device *_dev, struct device_attribute *attr, char *buf)
+static ssize_t net2280_show_registers(struct device *_dev,
+                               struct device_attribute *attr, char *buf)
 {
        struct net2280          *dev;
        char                    *next;
@@ -1668,7 +1571,7 @@ show_registers (struct device *_dev, struct device_attribute *attr, char *buf)
 
        return PAGE_SIZE - size;
 }
-static DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL);
+static DEVICE_ATTR(registers, S_IRUGO, net2280_show_registers, NULL);
 
 static ssize_t
 show_queues (struct device *_dev, struct device_attribute *attr, char *buf)
@@ -2532,7 +2435,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
                        break;
                default:
 delegate:
-                       VDEBUG (dev, "setup %02x.%02x v%04x i%04x l%04x"
+                       VDEBUG (dev, "setup %02x.%02x v%04x i%04x l%04x "
                                "ep_cfg %08x\n",
                                u.r.bRequestType, u.r.bRequest,
                                w_value, w_index, w_length,