aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/printer.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/printer.c')
-rw-r--r--drivers/usb/gadget/printer.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
index 978e6a101bf2..a341dde6f9c3 100644
--- a/drivers/usb/gadget/printer.c
+++ b/drivers/usb/gadget/printer.c
@@ -89,8 +89,7 @@ struct printer_dev {
89 u8 config; 89 u8 config;
90 s8 interface; 90 s8 interface;
91 struct usb_ep *in_ep, *out_ep; 91 struct usb_ep *in_ep, *out_ep;
92 const struct usb_endpoint_descriptor 92
93 *in, *out;
94 struct list_head rx_reqs; /* List of free RX structs */ 93 struct list_head rx_reqs; /* List of free RX structs */
95 struct list_head rx_reqs_active; /* List of Active RX xfers */ 94 struct list_head rx_reqs_active; /* List of Active RX xfers */
96 struct list_head rx_buffers; /* List of completed xfers */ 95 struct list_head rx_buffers; /* List of completed xfers */
@@ -898,19 +897,20 @@ set_printer_interface(struct printer_dev *dev)
898{ 897{
899 int result = 0; 898 int result = 0;
900 899
901 dev->in = ep_desc(dev->gadget, &hs_ep_in_desc, &fs_ep_in_desc); 900 dev->in_ep->desc = ep_desc(dev->gadget, &hs_ep_in_desc, &fs_ep_in_desc);
902 dev->in_ep->driver_data = dev; 901 dev->in_ep->driver_data = dev;
903 902
904 dev->out = ep_desc(dev->gadget, &hs_ep_out_desc, &fs_ep_out_desc); 903 dev->out_ep->desc = ep_desc(dev->gadget, &hs_ep_out_desc,
904 &fs_ep_out_desc);
905 dev->out_ep->driver_data = dev; 905 dev->out_ep->driver_data = dev;
906 906
907 result = usb_ep_enable(dev->in_ep, dev->in); 907 result = usb_ep_enable(dev->in_ep);
908 if (result != 0) { 908 if (result != 0) {
909 DBG(dev, "enable %s --> %d\n", dev->in_ep->name, result); 909 DBG(dev, "enable %s --> %d\n", dev->in_ep->name, result);
910 goto done; 910 goto done;
911 } 911 }
912 912
913 result = usb_ep_enable(dev->out_ep, dev->out); 913 result = usb_ep_enable(dev->out_ep);
914 if (result != 0) { 914 if (result != 0) {
915 DBG(dev, "enable %s --> %d\n", dev->in_ep->name, result); 915 DBG(dev, "enable %s --> %d\n", dev->in_ep->name, result);
916 goto done; 916 goto done;
@@ -921,8 +921,8 @@ done:
921 if (result != 0) { 921 if (result != 0) {
922 (void) usb_ep_disable(dev->in_ep); 922 (void) usb_ep_disable(dev->in_ep);
923 (void) usb_ep_disable(dev->out_ep); 923 (void) usb_ep_disable(dev->out_ep);
924 dev->in = NULL; 924 dev->in_ep->desc = NULL;
925 dev->out = NULL; 925 dev->out_ep->desc = NULL;
926 } 926 }
927 927
928 /* caller is responsible for cleanup on error */ 928 /* caller is responsible for cleanup on error */
@@ -936,12 +936,14 @@ static void printer_reset_interface(struct printer_dev *dev)
936 936
937 DBG(dev, "%s\n", __func__); 937 DBG(dev, "%s\n", __func__);
938 938
939 if (dev->in) 939 if (dev->in_ep->desc)
940 usb_ep_disable(dev->in_ep); 940 usb_ep_disable(dev->in_ep);
941 941
942 if (dev->out) 942 if (dev->out_ep->desc)
943 usb_ep_disable(dev->out_ep); 943 usb_ep_disable(dev->out_ep);
944 944
945 dev->in_ep->desc = NULL;
946 dev->out_ep->desc = NULL;
945 dev->interface = -1; 947 dev->interface = -1;
946} 948}
947 949
@@ -1107,9 +1109,9 @@ static void printer_soft_reset(struct printer_dev *dev)
1107 list_add(&req->list, &dev->tx_reqs); 1109 list_add(&req->list, &dev->tx_reqs);
1108 } 1110 }
1109 1111
1110 if (usb_ep_enable(dev->in_ep, dev->in)) 1112 if (usb_ep_enable(dev->in_ep))
1111 DBG(dev, "Failed to enable USB in_ep\n"); 1113 DBG(dev, "Failed to enable USB in_ep\n");
1112 if (usb_ep_enable(dev->out_ep, dev->out)) 1114 if (usb_ep_enable(dev->out_ep))
1113 DBG(dev, "Failed to enable USB out_ep\n"); 1115 DBG(dev, "Failed to enable USB out_ep\n");
1114 1116
1115 wake_up_interruptible(&dev->rx_wait); 1117 wake_up_interruptible(&dev->rx_wait);
@@ -1149,6 +1151,8 @@ printer_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1149 switch (wValue >> 8) { 1151 switch (wValue >> 8) {
1150 1152
1151 case USB_DT_DEVICE: 1153 case USB_DT_DEVICE:
1154 device_desc.bMaxPacketSize0 =
1155 gadget->ep0->maxpacket;
1152 value = min(wLength, (u16) sizeof device_desc); 1156 value = min(wLength, (u16) sizeof device_desc);
1153 memcpy(req->buf, &device_desc, value); 1157 memcpy(req->buf, &device_desc, value);
1154 break; 1158 break;
@@ -1156,6 +1160,12 @@ printer_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1156 case USB_DT_DEVICE_QUALIFIER: 1160 case USB_DT_DEVICE_QUALIFIER:
1157 if (!gadget->is_dualspeed) 1161 if (!gadget->is_dualspeed)
1158 break; 1162 break;
1163 /*
1164 * assumes ep0 uses the same value for both
1165 * speeds
1166 */
1167 dev_qualifier.bMaxPacketSize0 =
1168 gadget->ep0->maxpacket;
1159 value = min(wLength, 1169 value = min(wLength,
1160 (u16) sizeof dev_qualifier); 1170 (u16) sizeof dev_qualifier);
1161 memcpy(req->buf, &dev_qualifier, value); 1171 memcpy(req->buf, &dev_qualifier, value);
@@ -1451,15 +1461,11 @@ autoconf_fail:
1451 out_ep->driver_data = out_ep; /* claim */ 1461 out_ep->driver_data = out_ep; /* claim */
1452 1462
1453#ifdef CONFIG_USB_GADGET_DUALSPEED 1463#ifdef CONFIG_USB_GADGET_DUALSPEED
1454 /* assumes ep0 uses the same value for both speeds ... */ 1464 /* assumes that all endpoints are dual-speed */
1455 dev_qualifier.bMaxPacketSize0 = device_desc.bMaxPacketSize0;
1456
1457 /* and that all endpoints are dual-speed */
1458 hs_ep_in_desc.bEndpointAddress = fs_ep_in_desc.bEndpointAddress; 1465 hs_ep_in_desc.bEndpointAddress = fs_ep_in_desc.bEndpointAddress;
1459 hs_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress; 1466 hs_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress;
1460#endif /* DUALSPEED */ 1467#endif /* DUALSPEED */
1461 1468
1462 device_desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
1463 usb_gadget_set_selfpowered(gadget); 1469 usb_gadget_set_selfpowered(gadget);
1464 1470
1465 if (gadget->is_otg) { 1471 if (gadget->is_otg) {