diff options
author | Roger Quadros <rogerq@ti.com> | 2012-11-26 10:59:22 -0500 |
---|---|---|
committer | Roger Quadros <rogerq@ti.com> | 2013-02-13 06:22:47 -0500 |
commit | 27d4f2c654e39bed13374af9537633de414057b6 (patch) | |
tree | 378a52f980af2c1c9664e22b48ba9a63c9c510db | |
parent | a1f0d7a1f8cede5585c13c2f1c79e86a05d425ec (diff) |
mfd: omap-usb-host: Use devm_kzalloc() and devm_request_and_ioremap()
Use devm_ variants of kzalloc and ioremap. Also clean up error path.
Signed-off-by: Roger Quadros <rogerq@ti.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/mfd/omap-usb-host.c | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c index 061366dce8f6..310aaa9731ee 100644 --- a/drivers/mfd/omap-usb-host.c +++ b/drivers/mfd/omap-usb-host.c | |||
@@ -461,15 +461,20 @@ static int usbhs_omap_probe(struct platform_device *pdev) | |||
461 | 461 | ||
462 | if (!pdata) { | 462 | if (!pdata) { |
463 | dev_err(dev, "Missing platform data\n"); | 463 | dev_err(dev, "Missing platform data\n"); |
464 | ret = -ENOMEM; | 464 | return -ENODEV; |
465 | goto end_probe; | ||
466 | } | 465 | } |
467 | 466 | ||
468 | omap = kzalloc(sizeof(*omap), GFP_KERNEL); | 467 | omap = devm_kzalloc(dev, sizeof(*omap), GFP_KERNEL); |
469 | if (!omap) { | 468 | if (!omap) { |
470 | dev_err(dev, "Memory allocation failed\n"); | 469 | dev_err(dev, "Memory allocation failed\n"); |
471 | ret = -ENOMEM; | 470 | return -ENOMEM; |
472 | goto end_probe; | 471 | } |
472 | |||
473 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "uhh"); | ||
474 | omap->uhh_base = devm_request_and_ioremap(dev, res); | ||
475 | if (!omap->uhh_base) { | ||
476 | dev_err(dev, "Resource request/ioremap failed\n"); | ||
477 | return -EADDRNOTAVAIL; | ||
473 | } | 478 | } |
474 | 479 | ||
475 | spin_lock_init(&omap->lock); | 480 | spin_lock_init(&omap->lock); |
@@ -568,20 +573,6 @@ static int usbhs_omap_probe(struct platform_device *pdev) | |||
568 | "failed error:%d\n", ret); | 573 | "failed error:%d\n", ret); |
569 | } | 574 | } |
570 | 575 | ||
571 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "uhh"); | ||
572 | if (!res) { | ||
573 | dev_err(dev, "UHH EHCI get resource failed\n"); | ||
574 | ret = -ENODEV; | ||
575 | goto err_init_60m_fclk; | ||
576 | } | ||
577 | |||
578 | omap->uhh_base = ioremap(res->start, resource_size(res)); | ||
579 | if (!omap->uhh_base) { | ||
580 | dev_err(dev, "UHH ioremap failed\n"); | ||
581 | ret = -ENOMEM; | ||
582 | goto err_init_60m_fclk; | ||
583 | } | ||
584 | |||
585 | platform_set_drvdata(pdev, omap); | 576 | platform_set_drvdata(pdev, omap); |
586 | 577 | ||
587 | omap_usbhs_init(dev); | 578 | omap_usbhs_init(dev); |
@@ -591,13 +582,10 @@ static int usbhs_omap_probe(struct platform_device *pdev) | |||
591 | goto err_alloc; | 582 | goto err_alloc; |
592 | } | 583 | } |
593 | 584 | ||
594 | goto end_probe; | 585 | return 0; |
595 | 586 | ||
596 | err_alloc: | 587 | err_alloc: |
597 | omap_usbhs_deinit(&pdev->dev); | 588 | omap_usbhs_deinit(&pdev->dev); |
598 | iounmap(omap->uhh_base); | ||
599 | |||
600 | err_init_60m_fclk: | ||
601 | clk_put(omap->init_60m_fclk); | 589 | clk_put(omap->init_60m_fclk); |
602 | 590 | ||
603 | err_usbhost_p2_fck: | 591 | err_usbhost_p2_fck: |
@@ -621,9 +609,7 @@ err_utmi_p1_fck: | |||
621 | err_end: | 609 | err_end: |
622 | clk_put(omap->ehci_logic_fck); | 610 | clk_put(omap->ehci_logic_fck); |
623 | pm_runtime_disable(dev); | 611 | pm_runtime_disable(dev); |
624 | kfree(omap); | ||
625 | 612 | ||
626 | end_probe: | ||
627 | return ret; | 613 | return ret; |
628 | } | 614 | } |
629 | 615 | ||
@@ -638,7 +624,6 @@ static int usbhs_omap_remove(struct platform_device *pdev) | |||
638 | struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev); | 624 | struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev); |
639 | 625 | ||
640 | omap_usbhs_deinit(&pdev->dev); | 626 | omap_usbhs_deinit(&pdev->dev); |
641 | iounmap(omap->uhh_base); | ||
642 | clk_put(omap->init_60m_fclk); | 627 | clk_put(omap->init_60m_fclk); |
643 | clk_put(omap->usbhost_p2_fck); | 628 | clk_put(omap->usbhost_p2_fck); |
644 | clk_put(omap->usbhost_p1_fck); | 629 | clk_put(omap->usbhost_p1_fck); |
@@ -648,7 +633,6 @@ static int usbhs_omap_remove(struct platform_device *pdev) | |||
648 | clk_put(omap->utmi_p1_fck); | 633 | clk_put(omap->utmi_p1_fck); |
649 | clk_put(omap->ehci_logic_fck); | 634 | clk_put(omap->ehci_logic_fck); |
650 | pm_runtime_disable(&pdev->dev); | 635 | pm_runtime_disable(&pdev->dev); |
651 | kfree(omap); | ||
652 | 636 | ||
653 | return 0; | 637 | return 0; |
654 | } | 638 | } |