aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2012-09-10 09:01:51 -0400
committerFelipe Balbi <balbi@ti.com>2012-09-10 09:00:01 -0400
commite13f17ff8854e04cfc6b9f981a974f55d8da9b92 (patch)
tree9342ea309b44de0d0869d10728d03ad06ecd67f7
parentdc995fc27c2e1c8edebfb2405ede23bd38153f7f (diff)
usb: gadget: move USB_BUFSIZ into global composite.h
This patch moves USB_BUFSIZ into global header file as USB_COMP_EP0_BUFSIZ. There is currently only one user (f_sourcesink) besides composite which need it. Ideally f_sourcesink would have its own ep0 buffer. Lets keep it that way it was for now. Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/gadget/composite.c10
-rw-r--r--drivers/usb/gadget/f_sourcesink.c2
-rw-r--r--include/linux/usb/composite.h3
3 files changed, 8 insertions, 7 deletions
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 0b6ee2012af1..52689ee9db12 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -28,9 +28,6 @@
28 * with the relevant device-wide data. 28 * with the relevant device-wide data.
29 */ 29 */
30 30
31/* big enough to hold our biggest descriptor */
32#define USB_BUFSIZ 1024
33
34/* Some systems will need runtime overrides for the product identifiers 31/* Some systems will need runtime overrides for the product identifiers
35 * published in the device descriptor, either numbers or strings or both. 32 * published in the device descriptor, either numbers or strings or both.
36 * String parameters are in UTF-8 (superset of ASCII's 7 bit characters). 33 * String parameters are in UTF-8 (superset of ASCII's 7 bit characters).
@@ -355,10 +352,11 @@ static int config_buf(struct usb_configuration *config,
355{ 352{
356 struct usb_config_descriptor *c = buf; 353 struct usb_config_descriptor *c = buf;
357 void *next = buf + USB_DT_CONFIG_SIZE; 354 void *next = buf + USB_DT_CONFIG_SIZE;
358 int len = USB_BUFSIZ - USB_DT_CONFIG_SIZE; 355 int len;
359 struct usb_function *f; 356 struct usb_function *f;
360 int status; 357 int status;
361 358
359 len = USB_COMP_EP0_BUFSIZ - USB_DT_CONFIG_SIZE;
362 /* write the config descriptor */ 360 /* write the config descriptor */
363 c = buf; 361 c = buf;
364 c->bLength = USB_DT_CONFIG_SIZE; 362 c->bLength = USB_DT_CONFIG_SIZE;
@@ -1445,13 +1443,13 @@ static int composite_bind(struct usb_gadget *gadget,
1445 cdev->req = usb_ep_alloc_request(gadget->ep0, GFP_KERNEL); 1443 cdev->req = usb_ep_alloc_request(gadget->ep0, GFP_KERNEL);
1446 if (!cdev->req) 1444 if (!cdev->req)
1447 goto fail; 1445 goto fail;
1448 cdev->req->buf = kmalloc(USB_BUFSIZ, GFP_KERNEL); 1446 cdev->req->buf = kmalloc(USB_COMP_EP0_BUFSIZ, GFP_KERNEL);
1449 if (!cdev->req->buf) 1447 if (!cdev->req->buf)
1450 goto fail; 1448 goto fail;
1451 cdev->req->complete = composite_setup_complete; 1449 cdev->req->complete = composite_setup_complete;
1452 gadget->ep0->driver_data = cdev; 1450 gadget->ep0->driver_data = cdev;
1453 1451
1454 cdev->bufsiz = USB_BUFSIZ; 1452 cdev->bufsiz = USB_COMP_EP0_BUFSIZ;
1455 cdev->driver = composite; 1453 cdev->driver = composite;
1456 1454
1457 /* 1455 /*
diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c
index 5c1b68b63c98..3c126fde6e7e 100644
--- a/drivers/usb/gadget/f_sourcesink.c
+++ b/drivers/usb/gadget/f_sourcesink.c
@@ -795,7 +795,7 @@ static int sourcesink_setup(struct usb_configuration *c,
795 u16 w_value = le16_to_cpu(ctrl->wValue); 795 u16 w_value = le16_to_cpu(ctrl->wValue);
796 u16 w_length = le16_to_cpu(ctrl->wLength); 796 u16 w_length = le16_to_cpu(ctrl->wLength);
797 797
798 req->length = USB_BUFSIZ; 798 req->length = USB_COMP_EP0_BUFSIZ;
799 799
800 /* composite driver infrastructure handles everything except 800 /* composite driver infrastructure handles everything except
801 * the two control test requests. 801 * the two control test requests.
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 43d6b9ca51b7..89d91b671eb0 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -46,6 +46,9 @@
46 */ 46 */
47#define USB_GADGET_DELAYED_STATUS 0x7fff /* Impossibly large value */ 47#define USB_GADGET_DELAYED_STATUS 0x7fff /* Impossibly large value */
48 48
49/* big enough to hold our biggest descriptor */
50#define USB_COMP_EP0_BUFSIZ 1024
51
49struct usb_configuration; 52struct usb_configuration;
50 53
51/** 54/**