aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/davinci.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2013-09-19 19:14:38 -0400
committerFelipe Balbi <balbi@ti.com>2013-10-01 10:31:19 -0400
commitaf3848757204a16670d7da94f72beb45564955cc (patch)
tree610a8cf402a97addcadea54b19abd4e52ea7c4d7 /drivers/usb/musb/davinci.c
parentd1d7e3f537d3cddc79f51c2f0285991446fb6837 (diff)
usb: musb: use platform_device_register_full() to avoid directly messing with dma masks
Use platform_device_register_full() for those drivers which can, to avoid messing directly with DMA masks. This can only be done when the driver does not need to access the allocated musb platform device from within its callbacks, which may be called during the musb device probing. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb/davinci.c')
-rw-r--r--drivers/usb/musb/davinci.c48
1 files changed, 17 insertions, 31 deletions
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index ed0834e2b72e..45aae0bbb8df 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -505,7 +505,11 @@ static const struct musb_platform_ops davinci_ops = {
505 .set_vbus = davinci_musb_set_vbus, 505 .set_vbus = davinci_musb_set_vbus,
506}; 506};
507 507
508static u64 davinci_dmamask = DMA_BIT_MASK(32); 508static const struct platform_device_info davinci_dev_info = {
509 .name = "musb-hdrc",
510 .id = PLATFORM_DEVID_AUTO,
511 .dma_mask = DMA_BIT_MASK(32),
512};
509 513
510static int davinci_probe(struct platform_device *pdev) 514static int davinci_probe(struct platform_device *pdev)
511{ 515{
@@ -513,6 +517,7 @@ static int davinci_probe(struct platform_device *pdev)
513 struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev); 517 struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev);
514 struct platform_device *musb; 518 struct platform_device *musb;
515 struct davinci_glue *glue; 519 struct davinci_glue *glue;
520 struct platform_device_info pinfo;
516 struct clk *clk; 521 struct clk *clk;
517 522
518 int ret = -ENOMEM; 523 int ret = -ENOMEM;
@@ -523,12 +528,6 @@ static int davinci_probe(struct platform_device *pdev)
523 goto err0; 528 goto err0;
524 } 529 }
525 530
526 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
527 if (!musb) {
528 dev_err(&pdev->dev, "failed to allocate musb device\n");
529 goto err1;
530 }
531
532 clk = clk_get(&pdev->dev, "usb"); 531 clk = clk_get(&pdev->dev, "usb");
533 if (IS_ERR(clk)) { 532 if (IS_ERR(clk)) {
534 dev_err(&pdev->dev, "failed to get clock\n"); 533 dev_err(&pdev->dev, "failed to get clock\n");
@@ -542,12 +541,7 @@ static int davinci_probe(struct platform_device *pdev)
542 goto err4; 541 goto err4;
543 } 542 }
544 543
545 musb->dev.parent = &pdev->dev;
546 musb->dev.dma_mask = &davinci_dmamask;
547 musb->dev.coherent_dma_mask = davinci_dmamask;
548
549 glue->dev = &pdev->dev; 544 glue->dev = &pdev->dev;
550 glue->musb = musb;
551 glue->clk = clk; 545 glue->clk = clk;
552 546
553 pdata->platform_ops = &davinci_ops; 547 pdata->platform_ops = &davinci_ops;
@@ -567,22 +561,17 @@ static int davinci_probe(struct platform_device *pdev)
567 musb_resources[1].end = pdev->resource[1].end; 561 musb_resources[1].end = pdev->resource[1].end;
568 musb_resources[1].flags = pdev->resource[1].flags; 562 musb_resources[1].flags = pdev->resource[1].flags;
569 563
570 ret = platform_device_add_resources(musb, musb_resources, 564 pinfo = davinci_dev_info;
571 ARRAY_SIZE(musb_resources)); 565 pinfo.parent = &pdev->dev;
572 if (ret) { 566 pinfo.res = musb_resources;
573 dev_err(&pdev->dev, "failed to add resources\n"); 567 pinfo.num_res = ARRAY_SIZE(musb_resources);
574 goto err5; 568 pinfo.data = pdata;
575 } 569 pinfo.size_data = sizeof(*pdata);
576 570
577 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 571 glue->musb = musb = platform_device_register_full(&pinfo);
578 if (ret) { 572 if (IS_ERR(musb)) {
579 dev_err(&pdev->dev, "failed to add platform_data\n"); 573 ret = PTR_ERR(musb);
580 goto err5; 574 dev_err(&pdev->dev, "failed to register musb device: %d\n", ret);
581 }
582
583 ret = platform_device_add(musb);
584 if (ret) {
585 dev_err(&pdev->dev, "failed to register musb device\n");
586 goto err5; 575 goto err5;
587 } 576 }
588 577
@@ -595,9 +584,6 @@ err4:
595 clk_put(clk); 584 clk_put(clk);
596 585
597err3: 586err3:
598 platform_device_put(musb);
599
600err1:
601 kfree(glue); 587 kfree(glue);
602 588
603err0: 589err0: