diff options
author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2013-11-27 20:39:42 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-11-28 05:26:56 -0500 |
commit | b4dd05de3d6fb93724b27921689fb3e95ba71845 (patch) | |
tree | 8308e562bd619aa48ec1e4c0065138a1c5628550 /drivers/spi | |
parent | 7ad35442fc07689eea3e6357390ae7c8fd9ef53c (diff) |
spi: sh-msiof: Use devm_* managed allocators
This simplifies error and cleanup code paths.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-sh-msiof.c | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c index 86f822a656ef..7f2bb8572e5c 100644 --- a/drivers/spi/spi-sh-msiof.c +++ b/drivers/spi/spi-sh-msiof.c | |||
@@ -635,8 +635,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev) | |||
635 | master = spi_alloc_master(&pdev->dev, sizeof(struct sh_msiof_spi_priv)); | 635 | master = spi_alloc_master(&pdev->dev, sizeof(struct sh_msiof_spi_priv)); |
636 | if (master == NULL) { | 636 | if (master == NULL) { |
637 | dev_err(&pdev->dev, "failed to allocate spi master\n"); | 637 | dev_err(&pdev->dev, "failed to allocate spi master\n"); |
638 | ret = -ENOMEM; | 638 | return -ENOMEM; |
639 | goto err0; | ||
640 | } | 639 | } |
641 | 640 | ||
642 | p = spi_master_get_devdata(master); | 641 | p = spi_master_get_devdata(master); |
@@ -655,32 +654,32 @@ static int sh_msiof_spi_probe(struct platform_device *pdev) | |||
655 | 654 | ||
656 | init_completion(&p->done); | 655 | init_completion(&p->done); |
657 | 656 | ||
658 | p->clk = clk_get(&pdev->dev, NULL); | 657 | p->clk = devm_clk_get(&pdev->dev, NULL); |
659 | if (IS_ERR(p->clk)) { | 658 | if (IS_ERR(p->clk)) { |
660 | dev_err(&pdev->dev, "cannot get clock\n"); | 659 | dev_err(&pdev->dev, "cannot get clock\n"); |
661 | ret = PTR_ERR(p->clk); | 660 | ret = PTR_ERR(p->clk); |
662 | goto err1; | 661 | goto err1; |
663 | } | 662 | } |
664 | 663 | ||
665 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
666 | i = platform_get_irq(pdev, 0); | 664 | i = platform_get_irq(pdev, 0); |
667 | if (!r || i < 0) { | 665 | if (i < 0) { |
668 | dev_err(&pdev->dev, "cannot get platform resources\n"); | 666 | dev_err(&pdev->dev, "cannot get platform IRQ\n"); |
669 | ret = -ENOENT; | 667 | ret = -ENOENT; |
670 | goto err2; | 668 | goto err1; |
671 | } | 669 | } |
672 | p->mapbase = ioremap_nocache(r->start, resource_size(r)); | 670 | |
673 | if (!p->mapbase) { | 671 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
674 | dev_err(&pdev->dev, "unable to ioremap\n"); | 672 | p->mapbase = devm_ioremap_resource(&pdev->dev, r); |
675 | ret = -ENXIO; | 673 | if (IS_ERR(p->mapbase)) { |
676 | goto err2; | 674 | ret = PTR_ERR(p->mapbase); |
675 | goto err1; | ||
677 | } | 676 | } |
678 | 677 | ||
679 | ret = request_irq(i, sh_msiof_spi_irq, 0, | 678 | ret = devm_request_irq(&pdev->dev, i, sh_msiof_spi_irq, 0, |
680 | dev_name(&pdev->dev), p); | 679 | dev_name(&pdev->dev), p); |
681 | if (ret) { | 680 | if (ret) { |
682 | dev_err(&pdev->dev, "unable to request irq\n"); | 681 | dev_err(&pdev->dev, "unable to request irq\n"); |
683 | goto err3; | 682 | goto err1; |
684 | } | 683 | } |
685 | 684 | ||
686 | p->pdev = pdev; | 685 | p->pdev = pdev; |
@@ -719,13 +718,8 @@ static int sh_msiof_spi_probe(struct platform_device *pdev) | |||
719 | return 0; | 718 | return 0; |
720 | 719 | ||
721 | pm_runtime_disable(&pdev->dev); | 720 | pm_runtime_disable(&pdev->dev); |
722 | err3: | ||
723 | iounmap(p->mapbase); | ||
724 | err2: | ||
725 | clk_put(p->clk); | ||
726 | err1: | 721 | err1: |
727 | spi_master_put(master); | 722 | spi_master_put(master); |
728 | err0: | ||
729 | return ret; | 723 | return ret; |
730 | } | 724 | } |
731 | 725 | ||
@@ -737,9 +731,6 @@ static int sh_msiof_spi_remove(struct platform_device *pdev) | |||
737 | ret = spi_bitbang_stop(&p->bitbang); | 731 | ret = spi_bitbang_stop(&p->bitbang); |
738 | if (!ret) { | 732 | if (!ret) { |
739 | pm_runtime_disable(&pdev->dev); | 733 | pm_runtime_disable(&pdev->dev); |
740 | free_irq(platform_get_irq(pdev, 0), p); | ||
741 | iounmap(p->mapbase); | ||
742 | clk_put(p->clk); | ||
743 | spi_master_put(p->bitbang.master); | 734 | spi_master_put(p->bitbang.master); |
744 | } | 735 | } |
745 | return ret; | 736 | return ret; |