aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2012-10-31 11:12:43 -0400
committerFelipe Balbi <balbi@ti.com>2012-11-01 06:32:23 -0400
commit2f7711642559851c187d09795a3eb51c2bde36ec (patch)
treecc0663e2d53d0f4d6a5355c51fd5e30c843cafcd /drivers
parentb18d26f6ad8f00ea5f7c6a12ea52627ca3c3c6e2 (diff)
usb: musb: remove hand-crafted id handling
This replaced the handcrafted id handling by the PLATFORM_DEVID_AUTO value which should do the same thing. This patch probably also fixes ux500 because I did not find the "musbid" variable to remove. And we close a tiny-unlikely race window becuase the old code gave the id back before device was destroyed in the remove case. [ balbi@ti.com : fixed up two failed hunks when applying patch ] Cc: B, Ravi <ravibabu@ti.com> Cc: Santhapuri, Damodar <damodar.santhapuri@ti.com> Cc: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com> Cc: Bob Liu <lliubbo@gmail.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/musb/am35x.c18
-rw-r--r--drivers/usb/musb/blackfin.c18
-rw-r--r--drivers/usb/musb/da8xx.c18
-rw-r--r--drivers/usb/musb/davinci.c18
-rw-r--r--drivers/usb/musb/musb_core.c30
-rw-r--r--drivers/usb/musb/musb_core.h2
-rw-r--r--drivers/usb/musb/musb_dsps.c26
-rw-r--r--drivers/usb/musb/omap2430.c24
-rw-r--r--drivers/usb/musb/tusb6010.c18
-rw-r--r--drivers/usb/musb/ux500.c18
10 files changed, 22 insertions, 168 deletions
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index fdfd779c35b3..3ff30b9a5894 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -459,7 +459,6 @@ static int __devinit am35x_probe(struct platform_device *pdev)
459 struct clk *clk; 459 struct clk *clk;
460 460
461 int ret = -ENOMEM; 461 int ret = -ENOMEM;
462 int musbid;
463 462
464 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 463 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
465 if (!glue) { 464 if (!glue) {
@@ -467,18 +466,10 @@ static int __devinit am35x_probe(struct platform_device *pdev)
467 goto err0; 466 goto err0;
468 } 467 }
469 468
470 /* get the musb id */ 469 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
471 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
472 if (musbid < 0) {
473 dev_err(&pdev->dev, "failed to allocate musb id\n");
474 ret = -ENOMEM;
475 goto err1;
476 }
477
478 musb = platform_device_alloc("musb-hdrc", musbid);
479 if (!musb) { 470 if (!musb) {
480 dev_err(&pdev->dev, "failed to allocate musb device\n"); 471 dev_err(&pdev->dev, "failed to allocate musb device\n");
481 goto err2; 472 goto err1;
482 } 473 }
483 474
484 phy_clk = clk_get(&pdev->dev, "fck"); 475 phy_clk = clk_get(&pdev->dev, "fck");
@@ -507,7 +498,6 @@ static int __devinit am35x_probe(struct platform_device *pdev)
507 goto err6; 498 goto err6;
508 } 499 }
509 500
510 musb->id = musbid;
511 musb->dev.parent = &pdev->dev; 501 musb->dev.parent = &pdev->dev;
512 musb->dev.dma_mask = &am35x_dmamask; 502 musb->dev.dma_mask = &am35x_dmamask;
513 musb->dev.coherent_dma_mask = am35x_dmamask; 503 musb->dev.coherent_dma_mask = am35x_dmamask;
@@ -557,9 +547,6 @@ err4:
557err3: 547err3:
558 platform_device_put(musb); 548 platform_device_put(musb);
559 549
560err2:
561 musb_put_id(&pdev->dev, musbid);
562
563err1: 550err1:
564 kfree(glue); 551 kfree(glue);
565 552
@@ -571,7 +558,6 @@ static int __devexit am35x_remove(struct platform_device *pdev)
571{ 558{
572 struct am35x_glue *glue = platform_get_drvdata(pdev); 559 struct am35x_glue *glue = platform_get_drvdata(pdev);
573 560
574 musb_put_id(&pdev->dev, glue->musb->id);
575 platform_device_unregister(glue->musb); 561 platform_device_unregister(glue->musb);
576 clk_disable(glue->clk); 562 clk_disable(glue->clk);
577 clk_disable(glue->phy_clk); 563 clk_disable(glue->phy_clk);
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 307e726a2bd7..7e4d60a41728 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -455,7 +455,6 @@ static int __devinit bfin_probe(struct platform_device *pdev)
455 struct bfin_glue *glue; 455 struct bfin_glue *glue;
456 456
457 int ret = -ENOMEM; 457 int ret = -ENOMEM;
458 int musbid;
459 458
460 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 459 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
461 if (!glue) { 460 if (!glue) {
@@ -463,21 +462,12 @@ static int __devinit bfin_probe(struct platform_device *pdev)
463 goto err0; 462 goto err0;
464 } 463 }
465 464
466 /* get the musb id */ 465 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
467 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
468 if (musbid < 0) {
469 dev_err(&pdev->dev, "failed to allocate musb id\n");
470 ret = -ENOMEM;
471 goto err1;
472 }
473
474 musb = platform_device_alloc("musb-hdrc", musbid);
475 if (!musb) { 466 if (!musb) {
476 dev_err(&pdev->dev, "failed to allocate musb device\n"); 467 dev_err(&pdev->dev, "failed to allocate musb device\n");
477 goto err2; 468 goto err1;
478 } 469 }
479 470
480 musb->id = musbid;
481 musb->dev.parent = &pdev->dev; 471 musb->dev.parent = &pdev->dev;
482 musb->dev.dma_mask = &bfin_dmamask; 472 musb->dev.dma_mask = &bfin_dmamask;
483 musb->dev.coherent_dma_mask = bfin_dmamask; 473 musb->dev.coherent_dma_mask = bfin_dmamask;
@@ -513,9 +503,6 @@ static int __devinit bfin_probe(struct platform_device *pdev)
513err3: 503err3:
514 platform_device_put(musb); 504 platform_device_put(musb);
515 505
516err2:
517 musb_put_id(&pdev->dev, musbid);
518
519err1: 506err1:
520 kfree(glue); 507 kfree(glue);
521 508
@@ -527,7 +514,6 @@ static int __devexit bfin_remove(struct platform_device *pdev)
527{ 514{
528 struct bfin_glue *glue = platform_get_drvdata(pdev); 515 struct bfin_glue *glue = platform_get_drvdata(pdev);
529 516
530 musb_put_id(&pdev->dev, glue->musb->id);
531 platform_device_unregister(glue->musb); 517 platform_device_unregister(glue->musb);
532 kfree(glue); 518 kfree(glue);
533 519
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index e94f556c6aea..67b8ae704e9a 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -480,7 +480,6 @@ static int __devinit da8xx_probe(struct platform_device *pdev)
480 struct clk *clk; 480 struct clk *clk;
481 481
482 int ret = -ENOMEM; 482 int ret = -ENOMEM;
483 int musbid;
484 483
485 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 484 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
486 if (!glue) { 485 if (!glue) {
@@ -488,18 +487,10 @@ static int __devinit da8xx_probe(struct platform_device *pdev)
488 goto err0; 487 goto err0;
489 } 488 }
490 489
491 /* get the musb id */ 490 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
492 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
493 if (musbid < 0) {
494 dev_err(&pdev->dev, "failed to allocate musb id\n");
495 ret = -ENOMEM;
496 goto err1;
497 }
498
499 musb = platform_device_alloc("musb-hdrc", musbid);
500 if (!musb) { 491 if (!musb) {
501 dev_err(&pdev->dev, "failed to allocate musb device\n"); 492 dev_err(&pdev->dev, "failed to allocate musb device\n");
502 goto err2; 493 goto err1;
503 } 494 }
504 495
505 clk = clk_get(&pdev->dev, "usb20"); 496 clk = clk_get(&pdev->dev, "usb20");
@@ -515,7 +506,6 @@ static int __devinit da8xx_probe(struct platform_device *pdev)
515 goto err4; 506 goto err4;
516 } 507 }
517 508
518 musb->id = musbid;
519 musb->dev.parent = &pdev->dev; 509 musb->dev.parent = &pdev->dev;
520 musb->dev.dma_mask = &da8xx_dmamask; 510 musb->dev.dma_mask = &da8xx_dmamask;
521 musb->dev.coherent_dma_mask = da8xx_dmamask; 511 musb->dev.coherent_dma_mask = da8xx_dmamask;
@@ -558,9 +548,6 @@ err4:
558err3: 548err3:
559 platform_device_put(musb); 549 platform_device_put(musb);
560 550
561err2:
562 musb_put_id(&pdev->dev, musbid);
563
564err1: 551err1:
565 kfree(glue); 552 kfree(glue);
566 553
@@ -572,7 +559,6 @@ static int __devexit da8xx_remove(struct platform_device *pdev)
572{ 559{
573 struct da8xx_glue *glue = platform_get_drvdata(pdev); 560 struct da8xx_glue *glue = platform_get_drvdata(pdev);
574 561
575 musb_put_id(&pdev->dev, glue->musb->id);
576 platform_device_unregister(glue->musb); 562 platform_device_unregister(glue->musb);
577 clk_disable(glue->clk); 563 clk_disable(glue->clk);
578 clk_put(glue->clk); 564 clk_put(glue->clk);
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 959a6d71e1d5..b3c0a943950c 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -512,7 +512,6 @@ static int __devinit davinci_probe(struct platform_device *pdev)
512 struct clk *clk; 512 struct clk *clk;
513 513
514 int ret = -ENOMEM; 514 int ret = -ENOMEM;
515 int musbid;
516 515
517 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 516 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
518 if (!glue) { 517 if (!glue) {
@@ -520,18 +519,10 @@ static int __devinit davinci_probe(struct platform_device *pdev)
520 goto err0; 519 goto err0;
521 } 520 }
522 521
523 /* get the musb id */ 522 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
524 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
525 if (musbid < 0) {
526 dev_err(&pdev->dev, "failed to allocate musb id\n");
527 ret = -ENOMEM;
528 goto err1;
529 }
530
531 musb = platform_device_alloc("musb-hdrc", musbid);
532 if (!musb) { 523 if (!musb) {
533 dev_err(&pdev->dev, "failed to allocate musb device\n"); 524 dev_err(&pdev->dev, "failed to allocate musb device\n");
534 goto err2; 525 goto err1;
535 } 526 }
536 527
537 clk = clk_get(&pdev->dev, "usb"); 528 clk = clk_get(&pdev->dev, "usb");
@@ -547,7 +538,6 @@ static int __devinit davinci_probe(struct platform_device *pdev)
547 goto err4; 538 goto err4;
548 } 539 }
549 540
550 musb->id = musbid;
551 musb->dev.parent = &pdev->dev; 541 musb->dev.parent = &pdev->dev;
552 musb->dev.dma_mask = &davinci_dmamask; 542 musb->dev.dma_mask = &davinci_dmamask;
553 musb->dev.coherent_dma_mask = davinci_dmamask; 543 musb->dev.coherent_dma_mask = davinci_dmamask;
@@ -590,9 +580,6 @@ err4:
590err3: 580err3:
591 platform_device_put(musb); 581 platform_device_put(musb);
592 582
593err2:
594 musb_put_id(&pdev->dev, musbid);
595
596err1: 583err1:
597 kfree(glue); 584 kfree(glue);
598 585
@@ -604,7 +591,6 @@ static int __devexit davinci_remove(struct platform_device *pdev)
604{ 591{
605 struct davinci_glue *glue = platform_get_drvdata(pdev); 592 struct davinci_glue *glue = platform_get_drvdata(pdev);
606 593
607 musb_put_id(&pdev->dev, glue->musb->id);
608 platform_device_unregister(glue->musb); 594 platform_device_unregister(glue->musb);
609 clk_disable(glue->clk); 595 clk_disable(glue->clk);
610 clk_put(glue->clk); 596 clk_put(glue->clk);
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 25a0d8e1be51..78037bfad96e 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -116,7 +116,6 @@
116 116
117#define MUSB_DRIVER_NAME "musb-hdrc" 117#define MUSB_DRIVER_NAME "musb-hdrc"
118const char musb_driver_name[] = MUSB_DRIVER_NAME; 118const char musb_driver_name[] = MUSB_DRIVER_NAME;
119static DEFINE_IDA(musb_ida);
120 119
121MODULE_DESCRIPTION(DRIVER_INFO); 120MODULE_DESCRIPTION(DRIVER_INFO);
122MODULE_AUTHOR(DRIVER_AUTHOR); 121MODULE_AUTHOR(DRIVER_AUTHOR);
@@ -133,35 +132,6 @@ static inline struct musb *dev_to_musb(struct device *dev)
133 132
134/*-------------------------------------------------------------------------*/ 133/*-------------------------------------------------------------------------*/
135 134
136int musb_get_id(struct device *dev, gfp_t gfp_mask)
137{
138 int ret;
139 int id;
140
141 ret = ida_pre_get(&musb_ida, gfp_mask);
142 if (!ret) {
143 dev_err(dev, "failed to reserve resource for id\n");
144 return -ENOMEM;
145 }
146
147 ret = ida_get_new(&musb_ida, &id);
148 if (ret < 0) {
149 dev_err(dev, "failed to allocate a new id\n");
150 return ret;
151 }
152
153 return id;
154}
155EXPORT_SYMBOL_GPL(musb_get_id);
156
157void musb_put_id(struct device *dev, int id)
158{
159
160 dev_dbg(dev, "removing id %d\n", id);
161 ida_remove(&musb_ida, id);
162}
163EXPORT_SYMBOL_GPL(musb_put_id);
164
165#ifndef CONFIG_BLACKFIN 135#ifndef CONFIG_BLACKFIN
166static int musb_ulpi_read(struct usb_phy *phy, u32 offset) 136static int musb_ulpi_read(struct usb_phy *phy, u32 offset)
167{ 137{
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 0cef3ceb52c3..7fb4819a6f11 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -522,8 +522,6 @@ extern const char musb_driver_name[];
522 522
523extern void musb_start(struct musb *musb); 523extern void musb_start(struct musb *musb);
524extern void musb_stop(struct musb *musb); 524extern void musb_stop(struct musb *musb);
525extern int musb_get_id(struct device *dev, gfp_t gfp_mask);
526extern void musb_put_id(struct device *dev, int id);
527 525
528extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src); 526extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src);
529extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst); 527extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst);
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 828d2a216d94..2d2cd37bc7ba 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -459,7 +459,7 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
459 struct resource *res; 459 struct resource *res;
460 struct resource resources[2]; 460 struct resource resources[2];
461 char res_name[10]; 461 char res_name[10];
462 int ret, musbid; 462 int ret;
463 463
464 /* get memory resource */ 464 /* get memory resource */
465 sprintf(res_name, "musb%d", id); 465 sprintf(res_name, "musb%d", id);
@@ -484,22 +484,14 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
484 resources[1] = *res; 484 resources[1] = *res;
485 resources[1].name = "mc"; 485 resources[1].name = "mc";
486 486
487 /* get the musb id */
488 musbid = musb_get_id(dev, GFP_KERNEL);
489 if (musbid < 0) {
490 dev_err(dev, "failed to allocate musb id\n");
491 ret = -ENOMEM;
492 goto err0;
493 }
494 /* allocate the child platform device */ 487 /* allocate the child platform device */
495 musb = platform_device_alloc("musb-hdrc", musbid); 488 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
496 if (!musb) { 489 if (!musb) {
497 dev_err(dev, "failed to allocate musb device\n"); 490 dev_err(dev, "failed to allocate musb device\n");
498 ret = -ENOMEM; 491 ret = -ENOMEM;
499 goto err1; 492 goto err0;
500 } 493 }
501 494
502 musb->id = musbid;
503 musb->dev.parent = dev; 495 musb->dev.parent = dev;
504 musb->dev.dma_mask = &musb_dmamask; 496 musb->dev.dma_mask = &musb_dmamask;
505 musb->dev.coherent_dma_mask = musb_dmamask; 497 musb->dev.coherent_dma_mask = musb_dmamask;
@@ -556,18 +548,10 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
556 548
557err2: 549err2:
558 platform_device_put(musb); 550 platform_device_put(musb);
559err1:
560 musb_put_id(dev, musbid);
561err0: 551err0:
562 return ret; 552 return ret;
563} 553}
564 554
565static void dsps_delete_musb_pdev(struct dsps_glue *glue, u8 id)
566{
567 musb_put_id(glue->dev, glue->musb[id]->id);
568 platform_device_unregister(glue->musb[id]);
569}
570
571static int __devinit dsps_probe(struct platform_device *pdev) 555static int __devinit dsps_probe(struct platform_device *pdev)
572{ 556{
573 struct device_node *np = pdev->dev.of_node; 557 struct device_node *np = pdev->dev.of_node;
@@ -627,7 +611,7 @@ static int __devinit dsps_probe(struct platform_device *pdev)
627 dev_err(&pdev->dev, "failed to create child pdev\n"); 611 dev_err(&pdev->dev, "failed to create child pdev\n");
628 /* release resources of previously created instances */ 612 /* release resources of previously created instances */
629 for (i--; i >= 0 ; i--) 613 for (i--; i >= 0 ; i--)
630 dsps_delete_musb_pdev(glue, i); 614 platform_device_unregister(glue->musb[i]);
631 goto err3; 615 goto err3;
632 } 616 }
633 } 617 }
@@ -652,7 +636,7 @@ static int __devexit dsps_remove(struct platform_device *pdev)
652 636
653 /* delete the child platform device */ 637 /* delete the child platform device */
654 for (i = 0; i < wrp->instances ; i++) 638 for (i = 0; i < wrp->instances ; i++)
655 dsps_delete_musb_pdev(glue, i); 639 platform_device_unregister(glue->musb[i]);
656 640
657 /* disable usbss clocks */ 641 /* disable usbss clocks */
658 pm_runtime_put(&pdev->dev); 642 pm_runtime_put(&pdev->dev);
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index a538fe17a966..dddd8f71a176 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -478,7 +478,6 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
478 struct musb_hdrc_config *config; 478 struct musb_hdrc_config *config;
479 struct resource *res; 479 struct resource *res;
480 int ret = -ENOMEM; 480 int ret = -ENOMEM;
481 int musbid;
482 481
483 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); 482 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
484 if (!glue) { 483 if (!glue) {
@@ -486,21 +485,12 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
486 goto err0; 485 goto err0;
487 } 486 }
488 487
489 /* get the musb id */ 488 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
490 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
491 if (musbid < 0) {
492 dev_err(&pdev->dev, "failed to allocate musb id\n");
493 ret = -ENOMEM;
494 goto err0;
495 }
496
497 musb = platform_device_alloc("musb-hdrc", musbid);
498 if (!musb) { 489 if (!musb) {
499 dev_err(&pdev->dev, "failed to allocate musb device\n"); 490 dev_err(&pdev->dev, "failed to allocate musb device\n");
500 goto err1; 491 goto err0;
501 } 492 }
502 493
503 musb->id = musbid;
504 musb->dev.parent = &pdev->dev; 494 musb->dev.parent = &pdev->dev;
505 musb->dev.dma_mask = &omap2430_dmamask; 495 musb->dev.dma_mask = &omap2430_dmamask;
506 musb->dev.coherent_dma_mask = omap2430_dmamask; 496 musb->dev.coherent_dma_mask = omap2430_dmamask;
@@ -521,7 +511,7 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
521 dev_err(&pdev->dev, 511 dev_err(&pdev->dev,
522 "failed to allocate musb platfrom data\n"); 512 "failed to allocate musb platfrom data\n");
523 ret = -ENOMEM; 513 ret = -ENOMEM;
524 goto err1; 514 goto err2;
525 } 515 }
526 516
527 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 517 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
@@ -529,14 +519,14 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
529 dev_err(&pdev->dev, 519 dev_err(&pdev->dev,
530 "failed to allocate musb board data\n"); 520 "failed to allocate musb board data\n");
531 ret = -ENOMEM; 521 ret = -ENOMEM;
532 goto err1; 522 goto err2;
533 } 523 }
534 524
535 config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL); 525 config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL);
536 if (!data) { 526 if (!data) {
537 dev_err(&pdev->dev, 527 dev_err(&pdev->dev,
538 "failed to allocate musb hdrc config\n"); 528 "failed to allocate musb hdrc config\n");
539 goto err1; 529 goto err2;
540 } 530 }
541 531
542 of_property_read_u32(np, "mode", (u32 *)&pdata->mode); 532 of_property_read_u32(np, "mode", (u32 *)&pdata->mode);
@@ -589,9 +579,6 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
589err2: 579err2:
590 platform_device_put(musb); 580 platform_device_put(musb);
591 581
592err1:
593 musb_put_id(&pdev->dev, musbid);
594
595err0: 582err0:
596 return ret; 583 return ret;
597} 584}
@@ -601,7 +588,6 @@ static int __devexit omap2430_remove(struct platform_device *pdev)
601 struct omap2430_glue *glue = platform_get_drvdata(pdev); 588 struct omap2430_glue *glue = platform_get_drvdata(pdev);
602 589
603 cancel_work_sync(&glue->omap_musb_mailbox_work); 590 cancel_work_sync(&glue->omap_musb_mailbox_work);
604 musb_put_id(&pdev->dev, glue->musb->id);
605 platform_device_unregister(glue->musb); 591 platform_device_unregister(glue->musb);
606 592
607 return 0; 593 return 0;
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 4454561c6f57..812719b683d1 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -1160,7 +1160,6 @@ static int __devinit tusb_probe(struct platform_device *pdev)
1160 struct tusb6010_glue *glue; 1160 struct tusb6010_glue *glue;
1161 1161
1162 int ret = -ENOMEM; 1162 int ret = -ENOMEM;
1163 int musbid;
1164 1163
1165 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 1164 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
1166 if (!glue) { 1165 if (!glue) {
@@ -1168,21 +1167,12 @@ static int __devinit tusb_probe(struct platform_device *pdev)
1168 goto err0; 1167 goto err0;
1169 } 1168 }
1170 1169
1171 /* get the musb id */ 1170 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
1172 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
1173 if (musbid < 0) {
1174 dev_err(&pdev->dev, "failed to allocate musb id\n");
1175 ret = -ENOMEM;
1176 goto err1;
1177 }
1178
1179 musb = platform_device_alloc("musb-hdrc", musbid);
1180 if (!musb) { 1171 if (!musb) {
1181 dev_err(&pdev->dev, "failed to allocate musb device\n"); 1172 dev_err(&pdev->dev, "failed to allocate musb device\n");
1182 goto err2; 1173 goto err1;
1183 } 1174 }
1184 1175
1185 musb->id = musbid;
1186 musb->dev.parent = &pdev->dev; 1176 musb->dev.parent = &pdev->dev;
1187 musb->dev.dma_mask = &tusb_dmamask; 1177 musb->dev.dma_mask = &tusb_dmamask;
1188 musb->dev.coherent_dma_mask = tusb_dmamask; 1178 musb->dev.coherent_dma_mask = tusb_dmamask;
@@ -1218,9 +1208,6 @@ static int __devinit tusb_probe(struct platform_device *pdev)
1218err3: 1208err3:
1219 platform_device_put(musb); 1209 platform_device_put(musb);
1220 1210
1221err2:
1222 musb_put_id(&pdev->dev, musbid);
1223
1224err1: 1211err1:
1225 kfree(glue); 1212 kfree(glue);
1226 1213
@@ -1232,7 +1219,6 @@ static int __devexit tusb_remove(struct platform_device *pdev)
1232{ 1219{
1233 struct tusb6010_glue *glue = platform_get_drvdata(pdev); 1220 struct tusb6010_glue *glue = platform_get_drvdata(pdev);
1234 1221
1235 musb_put_id(&pdev->dev, glue->musb->id);
1236 platform_device_unregister(glue->musb); 1222 platform_device_unregister(glue->musb);
1237 kfree(glue); 1223 kfree(glue);
1238 1224
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index 4197f307ae0f..5e9053eb4298 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -65,7 +65,6 @@ static int __devinit ux500_probe(struct platform_device *pdev)
65 struct platform_device *musb; 65 struct platform_device *musb;
66 struct ux500_glue *glue; 66 struct ux500_glue *glue;
67 struct clk *clk; 67 struct clk *clk;
68
69 int ret = -ENOMEM; 68 int ret = -ENOMEM;
70 69
71 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 70 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
@@ -74,18 +73,10 @@ static int __devinit ux500_probe(struct platform_device *pdev)
74 goto err0; 73 goto err0;
75 } 74 }
76 75
77 /* get the musb id */ 76 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
78 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
79 if (musbid < 0) {
80 dev_err(&pdev->dev, "failed to allocate musb id\n");
81 ret = -ENOMEM;
82 goto err1;
83 }
84
85 musb = platform_device_alloc("musb-hdrc", musbid);
86 if (!musb) { 77 if (!musb) {
87 dev_err(&pdev->dev, "failed to allocate musb device\n"); 78 dev_err(&pdev->dev, "failed to allocate musb device\n");
88 goto err2; 79 goto err1;
89 } 80 }
90 81
91 clk = clk_get(&pdev->dev, "usb"); 82 clk = clk_get(&pdev->dev, "usb");
@@ -101,7 +92,6 @@ static int __devinit ux500_probe(struct platform_device *pdev)
101 goto err4; 92 goto err4;
102 } 93 }
103 94
104 musb->id = musbid;
105 musb->dev.parent = &pdev->dev; 95 musb->dev.parent = &pdev->dev;
106 musb->dev.dma_mask = pdev->dev.dma_mask; 96 musb->dev.dma_mask = pdev->dev.dma_mask;
107 musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask; 97 musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask;
@@ -144,9 +134,6 @@ err4:
144err3: 134err3:
145 platform_device_put(musb); 135 platform_device_put(musb);
146 136
147err2:
148 musb_put_id(&pdev->dev, musbid);
149
150err1: 137err1:
151 kfree(glue); 138 kfree(glue);
152 139
@@ -158,7 +145,6 @@ static int __devexit ux500_remove(struct platform_device *pdev)
158{ 145{
159 struct ux500_glue *glue = platform_get_drvdata(pdev); 146 struct ux500_glue *glue = platform_get_drvdata(pdev);
160 147
161 musb_put_id(&pdev->dev, glue->musb->id);
162 platform_device_unregister(glue->musb); 148 platform_device_unregister(glue->musb);
163 clk_disable(glue->clk); 149 clk_disable(glue->clk);
164 clk_put(glue->clk); 150 clk_put(glue->clk);