Merge branch 'usb-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
[linux-2.6.git] / drivers / usb / gadget / printer.c
index 978e6a1..a341dde 100644 (file)
@@ -89,8 +89,7 @@ struct printer_dev {
        u8                      config;
        s8                      interface;
        struct usb_ep           *in_ep, *out_ep;
-       const struct usb_endpoint_descriptor
-                               *in, *out;
+
        struct list_head        rx_reqs;        /* List of free RX structs */
        struct list_head        rx_reqs_active; /* List of Active RX xfers */
        struct list_head        rx_buffers;     /* List of completed xfers */
@@ -898,19 +897,20 @@ set_printer_interface(struct printer_dev *dev)
 {
        int                     result = 0;
 
-       dev->in = ep_desc(dev->gadget, &hs_ep_in_desc, &fs_ep_in_desc);
+       dev->in_ep->desc = ep_desc(dev->gadget, &hs_ep_in_desc, &fs_ep_in_desc);
        dev->in_ep->driver_data = dev;
 
-       dev->out = ep_desc(dev->gadget, &hs_ep_out_desc, &fs_ep_out_desc);
+       dev->out_ep->desc = ep_desc(dev->gadget, &hs_ep_out_desc,
+                                   &fs_ep_out_desc);
        dev->out_ep->driver_data = dev;
 
-       result = usb_ep_enable(dev->in_ep, dev->in);
+       result = usb_ep_enable(dev->in_ep);
        if (result != 0) {
                DBG(dev, "enable %s --> %d\n", dev->in_ep->name, result);
                goto done;
        }
 
-       result = usb_ep_enable(dev->out_ep, dev->out);
+       result = usb_ep_enable(dev->out_ep);
        if (result != 0) {
                DBG(dev, "enable %s --> %d\n", dev->in_ep->name, result);
                goto done;
@@ -921,8 +921,8 @@ done:
        if (result != 0) {
                (void) usb_ep_disable(dev->in_ep);
                (void) usb_ep_disable(dev->out_ep);
-               dev->in = NULL;
-               dev->out = NULL;
+               dev->in_ep->desc = NULL;
+               dev->out_ep->desc = NULL;
        }
 
        /* caller is responsible for cleanup on error */
@@ -936,12 +936,14 @@ static void printer_reset_interface(struct printer_dev *dev)
 
        DBG(dev, "%s\n", __func__);
 
-       if (dev->in)
+       if (dev->in_ep->desc)
                usb_ep_disable(dev->in_ep);
 
-       if (dev->out)
+       if (dev->out_ep->desc)
                usb_ep_disable(dev->out_ep);
 
+       dev->in_ep->desc = NULL;
+       dev->out_ep->desc = NULL;
        dev->interface = -1;
 }
 
@@ -1107,9 +1109,9 @@ static void printer_soft_reset(struct printer_dev *dev)
                list_add(&req->list, &dev->tx_reqs);
        }
 
-       if (usb_ep_enable(dev->in_ep, dev->in))
+       if (usb_ep_enable(dev->in_ep))
                DBG(dev, "Failed to enable USB in_ep\n");
-       if (usb_ep_enable(dev->out_ep, dev->out))
+       if (usb_ep_enable(dev->out_ep))
                DBG(dev, "Failed to enable USB out_ep\n");
 
        wake_up_interruptible(&dev->rx_wait);
@@ -1149,6 +1151,8 @@ printer_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
                        switch (wValue >> 8) {
 
                        case USB_DT_DEVICE:
+                               device_desc.bMaxPacketSize0 =
+                                       gadget->ep0->maxpacket;
                                value = min(wLength, (u16) sizeof device_desc);
                                memcpy(req->buf, &device_desc, value);
                                break;
@@ -1156,6 +1160,12 @@ printer_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
                        case USB_DT_DEVICE_QUALIFIER:
                                if (!gadget->is_dualspeed)
                                        break;
+                               /*
+                                * assumes ep0 uses the same value for both
+                                * speeds
+                                */
+                               dev_qualifier.bMaxPacketSize0 =
+                                       gadget->ep0->maxpacket;
                                value = min(wLength,
                                                (u16) sizeof dev_qualifier);
                                memcpy(req->buf, &dev_qualifier, value);
@@ -1451,15 +1461,11 @@ autoconf_fail:
        out_ep->driver_data = out_ep;   /* claim */
 
 #ifdef CONFIG_USB_GADGET_DUALSPEED
-       /* assumes ep0 uses the same value for both speeds ... */
-       dev_qualifier.bMaxPacketSize0 = device_desc.bMaxPacketSize0;
-
-       /* and that all endpoints are dual-speed */
+       /* assumes that all endpoints are dual-speed */
        hs_ep_in_desc.bEndpointAddress = fs_ep_in_desc.bEndpointAddress;
        hs_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress;
 #endif /* DUALSPEED */
 
-       device_desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
        usb_gadget_set_selfpowered(gadget);
 
        if (gadget->is_otg) {