This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / drivers / usb / gadget / zero.c
index 4fa5e1c..d779790 100644 (file)
@@ -194,13 +194,8 @@ module_param (loopdefault, bool, S_IRUGO|S_IWUSR);
  * DO NOT REUSE THESE IDs with a protocol-incompatible driver!!  Ever!!
  * Instead:  allocate your own, using normal USB-IF procedures.
  */
-#ifndef        CONFIG_USB_ZERO_HNPTEST
 #define DRIVER_VENDOR_NUM      0x0525          /* NetChip */
 #define DRIVER_PRODUCT_NUM     0xa4a0          /* Linux-USB "Gadget Zero" */
-#else
-#define DRIVER_VENDOR_NUM      0x1a0a          /* OTG test device IDs */
-#define DRIVER_PRODUCT_NUM     0xbadd
-#endif
 
 /*-------------------------------------------------------------------------*/
 
@@ -264,14 +259,6 @@ loopback_config = {
        .bMaxPower =            1,      /* self-powered */
 };
 
-static struct usb_otg_descriptor
-otg_descriptor = {
-       .bLength =              sizeof otg_descriptor,
-       .bDescriptorType =      USB_DT_OTG,
-
-       .bmAttributes =         USB_OTG_SRP,
-};
-
 /* one interface in each configuration */
 
 static const struct usb_interface_descriptor
@@ -315,19 +302,17 @@ fs_sink_desc = {
 };
 
 static const struct usb_descriptor_header *fs_source_sink_function [] = {
-       (struct usb_descriptor_header *) &otg_descriptor,
        (struct usb_descriptor_header *) &source_sink_intf,
        (struct usb_descriptor_header *) &fs_sink_desc,
        (struct usb_descriptor_header *) &fs_source_desc,
-       NULL,
+       0,
 };
 
 static const struct usb_descriptor_header *fs_loopback_function [] = {
-       (struct usb_descriptor_header *) &otg_descriptor,
        (struct usb_descriptor_header *) &loopback_intf,
        (struct usb_descriptor_header *) &fs_sink_desc,
        (struct usb_descriptor_header *) &fs_source_desc,
-       NULL,
+       0,
 };
 
 #ifdef CONFIG_USB_GADGET_DUALSPEED
@@ -371,19 +356,17 @@ dev_qualifier = {
 };
 
 static const struct usb_descriptor_header *hs_source_sink_function [] = {
-       (struct usb_descriptor_header *) &otg_descriptor,
        (struct usb_descriptor_header *) &source_sink_intf,
        (struct usb_descriptor_header *) &hs_source_desc,
        (struct usb_descriptor_header *) &hs_sink_desc,
-       NULL,
+       0,
 };
 
 static const struct usb_descriptor_header *hs_loopback_function [] = {
-       (struct usb_descriptor_header *) &otg_descriptor,
        (struct usb_descriptor_header *) &loopback_intf,
        (struct usb_descriptor_header *) &hs_source_desc,
        (struct usb_descriptor_header *) &hs_sink_desc,
-       NULL,
+       0,
 };
 
 /* maxpacket and other transfer characteristics vary by speed. */
@@ -461,10 +444,6 @@ config_buf (struct usb_gadget *gadget,
                        ? fs_source_sink_function
                        : fs_loopback_function;
 
-       /* for now, don't advertise srp-only devices */
-       if (!gadget->is_otg)
-               function++;
-
        len = usb_gadget_config_buf (is_source_sink
                                        ? &source_sink_config
                                        : &loopback_config,
@@ -489,7 +468,7 @@ alloc_ep_req (struct usb_ep *ep, unsigned length)
                                &req->dma, GFP_ATOMIC);
                if (!req->buf) {
                        usb_ep_free_request (ep, req);
-                       req = NULL;
+                       req = 0;
                }
        }
        return req;
@@ -506,7 +485,7 @@ static void free_ep_req (struct usb_ep *ep, struct usb_request *req)
 
 /* optionally require specific source/sink data patterns  */
 
-static int
+static inline int
 check_read_data (
        struct zero_dev         *dev,
        struct usb_ep           *ep,
@@ -540,7 +519,7 @@ check_read_data (
        return 0;
 }
 
-static void
+static inline void
 reinit_write_data (
        struct zero_dev         *dev,
        struct usb_ep           *ep,
@@ -620,7 +599,7 @@ source_sink_start_ep (struct usb_ep *ep, int gfp_flags)
 
        req = alloc_ep_req (ep, buflen);
        if (!req)
-               return NULL;
+               return 0;
 
        memset (req->buf, 0, req->length);
        req->complete = source_sink_complete;
@@ -634,7 +613,7 @@ source_sink_start_ep (struct usb_ep *ep, int gfp_flags)
 
                ERROR (dev, "start %s --> %d\n", ep->name, status);
                free_ep_req (ep, req);
-               req = NULL;
+               req = 0;
        }
 
        return req;
@@ -825,14 +804,13 @@ static void zero_reset_config (struct zero_dev *dev)
         */
        if (dev->in_ep) {
                usb_ep_disable (dev->in_ep);
-               dev->in_ep = NULL;
+               dev->in_ep = 0;
        }
        if (dev->out_ep) {
                usb_ep_disable (dev->out_ep);
-               dev->out_ep = NULL;
+               dev->out_ep = 0;
        }
        dev->config = 0;
-       del_timer (&dev->resume);
 }
 
 /* change our operational config.  this code must agree with the code
@@ -924,7 +902,6 @@ zero_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
        /* usually this stores reply data in the pre-allocated ep0 buffer,
         * but config change events will reconfigure hardware.
         */
-       req->zero = 0;
        switch (ctrl->bRequest) {
 
        case USB_REQ_GET_DESCRIPTOR:
@@ -974,12 +951,6 @@ zero_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
        case USB_REQ_SET_CONFIGURATION:
                if (ctrl->bRequestType != 0)
                        goto unknown;
-               if (gadget->a_hnp_support)
-                       DBG (dev, "HNP available\n");
-               else if (gadget->a_alt_hnp_support)
-                       DBG (dev, "HNP needs a different root port\n");
-               else
-                       VDBG (dev, "HNP inactive\n");
                spin_lock (&dev->lock);
                value = zero_set_config (dev, ctrl->wValue, GFP_ATOMIC);
                spin_unlock (&dev->lock);
@@ -1066,8 +1037,6 @@ unknown:
        /* respond with data transfer before status phase? */
        if (value >= 0) {
                req->length = value;
-               req->zero = value < ctrl->wLength
-                               && (value % gadget->ep0->maxpacket) == 0;
                value = usb_ep_queue (gadget->ep0, req, GFP_ATOMIC);
                if (value < 0) {
                        DBG (dev, "ep_queue --> %d\n", value);
@@ -1109,10 +1078,8 @@ zero_autoresume (unsigned long _dev)
        /* normally the host would be woken up for something
         * more significant than just a timer firing...
         */
-       if (dev->gadget->speed != USB_SPEED_UNKNOWN) {
-               status = usb_gadget_wakeup (dev->gadget);
-               DBG (dev, "wakeup --> %d\n", status);
-       }
+       status = usb_gadget_wakeup (dev->gadget);
+       DBG (dev, "wakeup --> %d\n", status);
 }
 
 /*-------------------------------------------------------------------------*/
@@ -1129,7 +1096,7 @@ zero_unbind (struct usb_gadget *gadget)
                free_ep_req (gadget->ep0, dev->req);
        del_timer_sync (&dev->resume);
        kfree (dev);
-       set_gadget_data (gadget, NULL);
+       set_gadget_data (gadget, 0);
 }
 
 static int
@@ -1230,12 +1197,6 @@ autoconf_fail:
        hs_sink_desc.bEndpointAddress = fs_sink_desc.bEndpointAddress;
 #endif
 
-       if (gadget->is_otg) {
-               otg_descriptor.bmAttributes |= USB_OTG_HNP,
-               source_sink_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
-               loopback_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
-       }
-
        usb_gadget_set_selfpowered (gadget);
 
        init_timer (&dev->resume);