diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2013-02-25 01:57:26 -0500 |
---|---|---|
committer | Shawn Guo <shawn.guo@linaro.org> | 2013-04-04 09:22:43 -0400 |
commit | aaa20517c0880d021c4839eb172e8cfc03c43e21 (patch) | |
tree | 9224a04344cfd2b5f401730b11305e301af2c0c9 /drivers/dma/mxs-dma.c | |
parent | f30fb03d4d3abe2da86918a92df0964cdf933e82 (diff) |
dma: mxs-dma: use devm_* managed functions
Use devm_* managed functions to simplify probe() error handling.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers/dma/mxs-dma.c')
-rw-r--r-- | drivers/dma/mxs-dma.c | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c index 8f6d30d37c45..bb86f7ff55d9 100644 --- a/drivers/dma/mxs-dma.c +++ b/drivers/dma/mxs-dma.c | |||
@@ -674,7 +674,7 @@ static int __init mxs_dma_probe(struct platform_device *pdev) | |||
674 | struct resource *iores; | 674 | struct resource *iores; |
675 | int ret, i; | 675 | int ret, i; |
676 | 676 | ||
677 | mxs_dma = kzalloc(sizeof(*mxs_dma), GFP_KERNEL); | 677 | mxs_dma = devm_kzalloc(&pdev->dev, sizeof(*mxs_dma), GFP_KERNEL); |
678 | if (!mxs_dma) | 678 | if (!mxs_dma) |
679 | return -ENOMEM; | 679 | return -ENOMEM; |
680 | 680 | ||
@@ -689,24 +689,13 @@ static int __init mxs_dma_probe(struct platform_device *pdev) | |||
689 | mxs_dma->dev_id = dma_type->id; | 689 | mxs_dma->dev_id = dma_type->id; |
690 | 690 | ||
691 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 691 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
692 | mxs_dma->base = devm_ioremap_resource(&pdev->dev, iores); | ||
693 | if (IS_ERR(mxs_dma->base)) | ||
694 | return PTR_ERR(mxs_dma->base); | ||
692 | 695 | ||
693 | if (!request_mem_region(iores->start, resource_size(iores), | 696 | mxs_dma->clk = devm_clk_get(&pdev->dev, NULL); |
694 | pdev->name)) { | 697 | if (IS_ERR(mxs_dma->clk)) |
695 | ret = -EBUSY; | 698 | return PTR_ERR(mxs_dma->clk); |
696 | goto err_request_region; | ||
697 | } | ||
698 | |||
699 | mxs_dma->base = ioremap(iores->start, resource_size(iores)); | ||
700 | if (!mxs_dma->base) { | ||
701 | ret = -ENOMEM; | ||
702 | goto err_ioremap; | ||
703 | } | ||
704 | |||
705 | mxs_dma->clk = clk_get(&pdev->dev, NULL); | ||
706 | if (IS_ERR(mxs_dma->clk)) { | ||
707 | ret = PTR_ERR(mxs_dma->clk); | ||
708 | goto err_clk; | ||
709 | } | ||
710 | 699 | ||
711 | dma_cap_set(DMA_SLAVE, mxs_dma->dma_device.cap_mask); | 700 | dma_cap_set(DMA_SLAVE, mxs_dma->dma_device.cap_mask); |
712 | dma_cap_set(DMA_CYCLIC, mxs_dma->dma_device.cap_mask); | 701 | dma_cap_set(DMA_CYCLIC, mxs_dma->dma_device.cap_mask); |
@@ -732,7 +721,7 @@ static int __init mxs_dma_probe(struct platform_device *pdev) | |||
732 | 721 | ||
733 | ret = mxs_dma_init(mxs_dma); | 722 | ret = mxs_dma_init(mxs_dma); |
734 | if (ret) | 723 | if (ret) |
735 | goto err_init; | 724 | return ret; |
736 | 725 | ||
737 | mxs_dma->dma_device.dev = &pdev->dev; | 726 | mxs_dma->dma_device.dev = &pdev->dev; |
738 | 727 | ||
@@ -751,22 +740,12 @@ static int __init mxs_dma_probe(struct platform_device *pdev) | |||
751 | ret = dma_async_device_register(&mxs_dma->dma_device); | 740 | ret = dma_async_device_register(&mxs_dma->dma_device); |
752 | if (ret) { | 741 | if (ret) { |
753 | dev_err(mxs_dma->dma_device.dev, "unable to register\n"); | 742 | dev_err(mxs_dma->dma_device.dev, "unable to register\n"); |
754 | goto err_init; | 743 | return ret; |
755 | } | 744 | } |
756 | 745 | ||
757 | dev_info(mxs_dma->dma_device.dev, "initialized\n"); | 746 | dev_info(mxs_dma->dma_device.dev, "initialized\n"); |
758 | 747 | ||
759 | return 0; | 748 | return 0; |
760 | |||
761 | err_init: | ||
762 | clk_put(mxs_dma->clk); | ||
763 | err_clk: | ||
764 | iounmap(mxs_dma->base); | ||
765 | err_ioremap: | ||
766 | release_mem_region(iores->start, resource_size(iores)); | ||
767 | err_request_region: | ||
768 | kfree(mxs_dma); | ||
769 | return ret; | ||
770 | } | 749 | } |
771 | 750 | ||
772 | static struct platform_driver mxs_dma_driver = { | 751 | static struct platform_driver mxs_dma_driver = { |