aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/gadget/inode.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 9a4edc5657aa..0aab7d24c768 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -135,6 +135,7 @@ struct dev_data {
135 setup_out_ready : 1, 135 setup_out_ready : 1,
136 setup_out_error : 1, 136 setup_out_error : 1,
137 setup_abort : 1; 137 setup_abort : 1;
138 unsigned setup_wLength;
138 139
139 /* the rest is basically write-once */ 140 /* the rest is basically write-once */
140 struct usb_config_descriptor *config, *hs_config; 141 struct usb_config_descriptor *config, *hs_config;
@@ -942,6 +943,7 @@ static int setup_req (struct usb_ep *ep, struct usb_request *req, u16 len)
942 } 943 }
943 req->complete = ep0_complete; 944 req->complete = ep0_complete;
944 req->length = len; 945 req->length = len;
946 req->zero = 0;
945 return 0; 947 return 0;
946} 948}
947 949
@@ -1161,10 +1163,13 @@ ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1161 spin_unlock_irq (&dev->lock); 1163 spin_unlock_irq (&dev->lock);
1162 if (copy_from_user (dev->req->buf, buf, len)) 1164 if (copy_from_user (dev->req->buf, buf, len))
1163 retval = -EFAULT; 1165 retval = -EFAULT;
1164 else 1166 else {
1167 if (len < dev->setup_wLength)
1168 dev->req->zero = 1;
1165 retval = usb_ep_queue ( 1169 retval = usb_ep_queue (
1166 dev->gadget->ep0, dev->req, 1170 dev->gadget->ep0, dev->req,
1167 GFP_KERNEL); 1171 GFP_KERNEL);
1172 }
1168 if (retval < 0) { 1173 if (retval < 0) {
1169 spin_lock_irq (&dev->lock); 1174 spin_lock_irq (&dev->lock);
1170 clean_req (dev->gadget->ep0, dev->req); 1175 clean_req (dev->gadget->ep0, dev->req);
@@ -1483,6 +1488,7 @@ unrecognized:
1483delegate: 1488delegate:
1484 dev->setup_in = (ctrl->bRequestType & USB_DIR_IN) 1489 dev->setup_in = (ctrl->bRequestType & USB_DIR_IN)
1485 ? 1 : 0; 1490 ? 1 : 0;
1491 dev->setup_wLength = w_length;
1486 dev->setup_out_ready = 0; 1492 dev->setup_out_ready = 0;
1487 dev->setup_out_error = 0; 1493 dev->setup_out_error = 0;
1488 value = 0; 1494 value = 0;