diff options
author | Felipe Balbi <balbi@ti.com> | 2012-05-04 05:58:14 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-05-04 05:58:14 -0400 |
commit | 3ef35fafdc87b72851f7785dc5331a0f4eb1b3ce (patch) | |
tree | 83664ecb128f24e2c8cad82797eaa0f7ee7f311e /drivers/usb/dwc3 | |
parent | f898ae09a043cf9c3c4be82c04e08fcf00fe82c1 (diff) |
usb: dwc3: define DWC3_EP0_BOUNCE_SIZE
to avoid sprinkling magic constants on the driver
we define a constant to be used when allocating
setup_buffer and ep0_bounce buffer.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/dwc3')
-rw-r--r-- | drivers/usb/dwc3/core.h | 1 | ||||
-rw-r--r-- | drivers/usb/dwc3/gadget.c | 13 |
2 files changed, 8 insertions, 6 deletions
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index ef28bd5680c5..fbd0c8e30c19 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h | |||
@@ -51,6 +51,7 @@ | |||
51 | #include <linux/usb/gadget.h> | 51 | #include <linux/usb/gadget.h> |
52 | 52 | ||
53 | /* Global constants */ | 53 | /* Global constants */ |
54 | #define DWC3_EP0_BOUNCE_SIZE 512 | ||
54 | #define DWC3_ENDPOINTS_NUM 32 | 55 | #define DWC3_ENDPOINTS_NUM 32 |
55 | #define DWC3_XHCI_RESOURCES_NUM 2 | 56 | #define DWC3_XHCI_RESOURCES_NUM 2 |
56 | 57 | ||
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 31ffc5c27354..12844393bc3e 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
@@ -2319,7 +2319,7 @@ int __devinit dwc3_gadget_init(struct dwc3 *dwc) | |||
2319 | goto err1; | 2319 | goto err1; |
2320 | } | 2320 | } |
2321 | 2321 | ||
2322 | dwc->setup_buf = kzalloc(512, GFP_KERNEL); | 2322 | dwc->setup_buf = kzalloc(DWC3_EP0_BOUNCE_SIZE, GFP_KERNEL); |
2323 | if (!dwc->setup_buf) { | 2323 | if (!dwc->setup_buf) { |
2324 | dev_err(dwc->dev, "failed to allocate setup buffer\n"); | 2324 | dev_err(dwc->dev, "failed to allocate setup buffer\n"); |
2325 | ret = -ENOMEM; | 2325 | ret = -ENOMEM; |
@@ -2327,7 +2327,8 @@ int __devinit dwc3_gadget_init(struct dwc3 *dwc) | |||
2327 | } | 2327 | } |
2328 | 2328 | ||
2329 | dwc->ep0_bounce = dma_alloc_coherent(dwc->dev, | 2329 | dwc->ep0_bounce = dma_alloc_coherent(dwc->dev, |
2330 | 512, &dwc->ep0_bounce_addr, GFP_KERNEL); | 2330 | DWC3_EP0_BOUNCE_SIZE, &dwc->ep0_bounce_addr, |
2331 | GFP_KERNEL); | ||
2331 | if (!dwc->ep0_bounce) { | 2332 | if (!dwc->ep0_bounce) { |
2332 | dev_err(dwc->dev, "failed to allocate ep0 bounce buffer\n"); | 2333 | dev_err(dwc->dev, "failed to allocate ep0 bounce buffer\n"); |
2333 | ret = -ENOMEM; | 2334 | ret = -ENOMEM; |
@@ -2414,8 +2415,8 @@ err5: | |||
2414 | dwc3_gadget_free_endpoints(dwc); | 2415 | dwc3_gadget_free_endpoints(dwc); |
2415 | 2416 | ||
2416 | err4: | 2417 | err4: |
2417 | dma_free_coherent(dwc->dev, 512, dwc->ep0_bounce, | 2418 | dma_free_coherent(dwc->dev, DWC3_EP0_BOUNCE_SIZE, |
2418 | dwc->ep0_bounce_addr); | 2419 | dwc->ep0_bounce, dwc->ep0_bounce_addr); |
2419 | 2420 | ||
2420 | err3: | 2421 | err3: |
2421 | kfree(dwc->setup_buf); | 2422 | kfree(dwc->setup_buf); |
@@ -2444,8 +2445,8 @@ void dwc3_gadget_exit(struct dwc3 *dwc) | |||
2444 | 2445 | ||
2445 | dwc3_gadget_free_endpoints(dwc); | 2446 | dwc3_gadget_free_endpoints(dwc); |
2446 | 2447 | ||
2447 | dma_free_coherent(dwc->dev, 512, dwc->ep0_bounce, | 2448 | dma_free_coherent(dwc->dev, DWC3_EP0_BOUNCE_SIZE, |
2448 | dwc->ep0_bounce_addr); | 2449 | dwc->ep0_bounce, dwc->ep0_bounce_addr); |
2449 | 2450 | ||
2450 | kfree(dwc->setup_buf); | 2451 | kfree(dwc->setup_buf); |
2451 | 2452 | ||