aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKishon Vijay Abraham I <kishon@ti.com>2012-06-22 08:10:54 -0400
committerFelipe Balbi <balbi@ti.com>2012-06-25 07:08:51 -0400
commitb1183c242a60764afbdfaf39396405b7afa1106c (patch)
tree5a155a6c3dfbbf23c48f2b695be58c723785be78
parentc83a8542b5e3c5b30825955a68b1cc8bd24b122a (diff)
usb: musb: omap: use devres API to allocate resources
used devres API while allocating memory resource and while getting usb phy so that these resources are released automatically on driver detach. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/musb/omap2430.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index c4dc92bd7e85..2813490ba631 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -319,7 +319,7 @@ static int omap2430_musb_init(struct musb *musb)
319 * up through ULPI. TWL4030-family PMICs include one, 319 * up through ULPI. TWL4030-family PMICs include one,
320 * which needs a driver, drivers aren't always needed. 320 * which needs a driver, drivers aren't always needed.
321 */ 321 */
322 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); 322 musb->xceiv = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
323 if (!musb->xceiv) { 323 if (!musb->xceiv) {
324 pr_err("HS USB OTG: no transceiver configured\n"); 324 pr_err("HS USB OTG: no transceiver configured\n");
325 return -ENODEV; 325 return -ENODEV;
@@ -416,7 +416,6 @@ static int omap2430_musb_exit(struct musb *musb)
416 del_timer_sync(&musb_idle_timer); 416 del_timer_sync(&musb_idle_timer);
417 417
418 omap2430_low_level_exit(musb); 418 omap2430_low_level_exit(musb);
419 usb_put_phy(musb->xceiv);
420 419
421 return 0; 420 return 0;
422} 421}
@@ -443,7 +442,7 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
443 struct omap2430_glue *glue; 442 struct omap2430_glue *glue;
444 int ret = -ENOMEM; 443 int ret = -ENOMEM;
445 444
446 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 445 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
447 if (!glue) { 446 if (!glue) {
448 dev_err(&pdev->dev, "failed to allocate glue context\n"); 447 dev_err(&pdev->dev, "failed to allocate glue context\n");
449 goto err0; 448 goto err0;
@@ -452,7 +451,7 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
452 musb = platform_device_alloc("musb-hdrc", -1); 451 musb = platform_device_alloc("musb-hdrc", -1);
453 if (!musb) { 452 if (!musb) {
454 dev_err(&pdev->dev, "failed to allocate musb device\n"); 453 dev_err(&pdev->dev, "failed to allocate musb device\n");
455 goto err1; 454 goto err0;
456 } 455 }
457 456
458 musb->dev.parent = &pdev->dev; 457 musb->dev.parent = &pdev->dev;
@@ -479,13 +478,13 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
479 pdev->num_resources); 478 pdev->num_resources);
480 if (ret) { 479 if (ret) {
481 dev_err(&pdev->dev, "failed to add resources\n"); 480 dev_err(&pdev->dev, "failed to add resources\n");
482 goto err2; 481 goto err1;
483 } 482 }
484 483
485 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 484 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
486 if (ret) { 485 if (ret) {
487 dev_err(&pdev->dev, "failed to add platform_data\n"); 486 dev_err(&pdev->dev, "failed to add platform_data\n");
488 goto err2; 487 goto err1;
489 } 488 }
490 489
491 pm_runtime_enable(&pdev->dev); 490 pm_runtime_enable(&pdev->dev);
@@ -493,16 +492,13 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
493 ret = platform_device_add(musb); 492 ret = platform_device_add(musb);
494 if (ret) { 493 if (ret) {
495 dev_err(&pdev->dev, "failed to register musb device\n"); 494 dev_err(&pdev->dev, "failed to register musb device\n");
496 goto err2; 495 goto err1;
497 } 496 }
498 497
499 return 0; 498 return 0;
500 499
501err2:
502 platform_device_put(musb);
503
504err1: 500err1:
505 kfree(glue); 501 platform_device_put(musb);
506 502
507err0: 503err0:
508 return ret; 504 return ret;
@@ -515,7 +511,6 @@ static int __devexit omap2430_remove(struct platform_device *pdev)
515 cancel_work_sync(&glue->omap_musb_mailbox_work); 511 cancel_work_sync(&glue->omap_musb_mailbox_work);
516 platform_device_del(glue->musb); 512 platform_device_del(glue->musb);
517 platform_device_put(glue->musb); 513 platform_device_put(glue->musb);
518 kfree(glue);
519 514
520 return 0; 515 return 0;
521} 516}