diff options
author | Felipe Balbi <balbi@ti.com> | 2012-10-11 06:54:36 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-10-15 07:58:56 -0400 |
commit | 3921426b13b1e0b2db6872a8d22d9fe2a4afe332 (patch) | |
tree | cdc4cd76426fa93ea3ce72c1b6c78724835e3680 /drivers/usb/dwc3 | |
parent | 380f0d28431e852e07e3fa0d5f6e36cf9ea5aa5a (diff) |
usb: dwc3: core: move event buffer allocation out of dwc3_core_init()
This patch is in preparation for adding PM support
dwc3 driver. We want to re-use dwc3_core_init and
dwc3_core_exit() functions on resume() and suspend()
callbacks respectively.
Moving even buffer allocation away from dwc3_core_init()
will allow us to reuse the event buffer which was allocated
long ago on our probe() routine.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/dwc3')
-rw-r--r-- | drivers/usb/dwc3/core.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 8d543ea4352a..b923183c43cb 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -381,24 +381,14 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc) | |||
381 | 381 | ||
382 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); | 382 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); |
383 | 383 | ||
384 | ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); | ||
385 | if (ret) { | ||
386 | dev_err(dwc->dev, "failed to allocate event buffers\n"); | ||
387 | ret = -ENOMEM; | ||
388 | goto err1; | ||
389 | } | ||
390 | |||
391 | ret = dwc3_event_buffers_setup(dwc); | 384 | ret = dwc3_event_buffers_setup(dwc); |
392 | if (ret) { | 385 | if (ret) { |
393 | dev_err(dwc->dev, "failed to setup event buffers\n"); | 386 | dev_err(dwc->dev, "failed to setup event buffers\n"); |
394 | goto err1; | 387 | goto err0; |
395 | } | 388 | } |
396 | 389 | ||
397 | return 0; | 390 | return 0; |
398 | 391 | ||
399 | err1: | ||
400 | dwc3_free_event_buffers(dwc); | ||
401 | |||
402 | err0: | 392 | err0: |
403 | return ret; | 393 | return ret; |
404 | } | 394 | } |
@@ -406,7 +396,6 @@ err0: | |||
406 | static void dwc3_core_exit(struct dwc3 *dwc) | 396 | static void dwc3_core_exit(struct dwc3 *dwc) |
407 | { | 397 | { |
408 | dwc3_event_buffers_cleanup(dwc); | 398 | dwc3_event_buffers_cleanup(dwc); |
409 | dwc3_free_event_buffers(dwc); | ||
410 | } | 399 | } |
411 | 400 | ||
412 | #define DWC3_ALIGN_MASK (16 - 1) | 401 | #define DWC3_ALIGN_MASK (16 - 1) |
@@ -509,10 +498,17 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
509 | pm_runtime_get_sync(dev); | 498 | pm_runtime_get_sync(dev); |
510 | pm_runtime_forbid(dev); | 499 | pm_runtime_forbid(dev); |
511 | 500 | ||
501 | ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); | ||
502 | if (ret) { | ||
503 | dev_err(dwc->dev, "failed to allocate event buffers\n"); | ||
504 | ret = -ENOMEM; | ||
505 | goto err0; | ||
506 | } | ||
507 | |||
512 | ret = dwc3_core_init(dwc); | 508 | ret = dwc3_core_init(dwc); |
513 | if (ret) { | 509 | if (ret) { |
514 | dev_err(dev, "failed to initialize core\n"); | 510 | dev_err(dev, "failed to initialize core\n"); |
515 | return ret; | 511 | goto err0; |
516 | } | 512 | } |
517 | 513 | ||
518 | mode = DWC3_MODE(dwc->hwparams.hwparams0); | 514 | mode = DWC3_MODE(dwc->hwparams.hwparams0); |
@@ -584,6 +580,9 @@ err2: | |||
584 | err1: | 580 | err1: |
585 | dwc3_core_exit(dwc); | 581 | dwc3_core_exit(dwc); |
586 | 582 | ||
583 | err0: | ||
584 | dwc3_free_event_buffers(dwc); | ||
585 | |||
587 | return ret; | 586 | return ret; |
588 | } | 587 | } |
589 | 588 | ||