aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2010-12-02 02:42:50 -0500
committerFelipe Balbi <balbi@ti.com>2010-12-10 03:21:22 -0500
commita023c631f546ef95d58969385825a47652ab9039 (patch)
treedb76714c5ca83ab8fc8a0bdbff90603e0e3d4150 /drivers/usb/musb
parente6480faa1067af91ab403fd3aaf6db2fe1134b13 (diff)
usb: musb: blackfin: give it a context structure
that structure currently only holds a device pointer to our own platform_device and musb's platform_device, but soon it will hold pointers to our clock structures and glue-specific bits and pieces. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb')
-rw-r--r--drivers/usb/musb/blackfin.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index b0968201d849..02eded21d171 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -23,6 +23,11 @@
23#include "musb_core.h" 23#include "musb_core.h"
24#include "blackfin.h" 24#include "blackfin.h"
25 25
26struct bfin_glue {
27 struct device *dev;
28 struct platform_device *musb;
29};
30
26/* 31/*
27 * Load an endpoint's FIFO 32 * Load an endpoint's FIFO
28 */ 33 */
@@ -451,55 +456,69 @@ static int __init bfin_probe(struct platform_device *pdev)
451{ 456{
452 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; 457 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
453 struct platform_device *musb; 458 struct platform_device *musb;
459 struct bfin_glue *glue;
454 460
455 int ret = -ENOMEM; 461 int ret = -ENOMEM;
456 462
463 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
464 if (!glue) {
465 dev_err(&pdev->dev, "failed to allocate glue context\n");
466 goto err0;
467 }
468
457 musb = platform_device_alloc("musb-hdrc", -1); 469 musb = platform_device_alloc("musb-hdrc", -1);
458 if (!musb) { 470 if (!musb) {
459 dev_err(&pdev->dev, "failed to allocate musb device\n"); 471 dev_err(&pdev->dev, "failed to allocate musb device\n");
460 goto err0; 472 goto err1;
461 } 473 }
462 474
463 musb->dev.parent = &pdev->dev; 475 musb->dev.parent = &pdev->dev;
464 musb->dev.dma_mask = &bfin_dmamask; 476 musb->dev.dma_mask = &bfin_dmamask;
465 musb->dev.coherent_dma_mask = bfin_dmamask; 477 musb->dev.coherent_dma_mask = bfin_dmamask;
466 478
467 platform_set_drvdata(pdev, musb); 479 glue->dev = &pdev->dev;
480 glue->musb = musb;
481
482 platform_set_drvdata(pdev, glue);
468 483
469 ret = platform_device_add_resources(musb, pdev->resource, 484 ret = platform_device_add_resources(musb, pdev->resource,
470 pdev->num_resources); 485 pdev->num_resources);
471 if (ret) { 486 if (ret) {
472 dev_err(&pdev->dev, "failed to add resources\n"); 487 dev_err(&pdev->dev, "failed to add resources\n");
473 goto err1; 488 goto err2;
474 } 489 }
475 490
476 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 491 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
477 if (ret) { 492 if (ret) {
478 dev_err(&pdev->dev, "failed to add platform_data\n"); 493 dev_err(&pdev->dev, "failed to add platform_data\n");
479 goto err1; 494 goto err2;
480 } 495 }
481 496
482 ret = platform_device_add(musb); 497 ret = platform_device_add(musb);
483 if (ret) { 498 if (ret) {
484 dev_err(&pdev->dev, "failed to register musb device\n"); 499 dev_err(&pdev->dev, "failed to register musb device\n");
485 goto err1; 500 goto err2;
486 } 501 }
487 502
488 return 0; 503 return 0;
489 504
490err1: 505err2:
491 platform_device_put(musb); 506 platform_device_put(musb);
492 507
508err1:
509 kfree(glue);
510
493err0: 511err0:
494 return ret; 512 return ret;
495} 513}
496 514
497static int __exit bfin_remove(struct platform_device *pdev) 515static int __exit bfin_remove(struct platform_device *pdev)
498{ 516{
499 struct platform_device *musb = platform_get_drvdata(pdev); 517 struct bfin_glue *glue = platform_get_drvdata(pdev);
500 518
501 platform_device_del(musb); 519 platform_device_del(glue->musb);
502 platform_device_put(musb); 520 platform_device_put(glue->musb);
521 kfree(glue);
503 522
504 return 0; 523 return 0;
505} 524}