diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2013-05-29 07:39:10 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2013-06-05 04:43:07 -0400 |
commit | 0bc8a7188ff1b9b1cca2e49fd78f0e1797a75631 (patch) | |
tree | 5ae92c4fad6705d2bcf4f27bb94bfb076a7a1614 | |
parent | d6dfd683e6b196db4cf92cf226c9f63ee66a5eb1 (diff) |
crypto: dcp - Use devm_* APIs
devm_* APIs are device managed and make cleanup and exit
code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Tested-by: Tobias Rauter <tobiasrauter@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/crypto/dcp.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/drivers/crypto/dcp.c b/drivers/crypto/dcp.c index 83eaefcefb64..9e91c2cf3bf8 100644 --- a/drivers/crypto/dcp.c +++ b/drivers/crypto/dcp.c | |||
@@ -723,12 +723,10 @@ static int dcp_probe(struct platform_device *pdev) | |||
723 | struct resource *r; | 723 | struct resource *r; |
724 | int i, ret, j; | 724 | int i, ret, j; |
725 | 725 | ||
726 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | 726 | dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); |
727 | if (dev == NULL) { | 727 | if (!dev) |
728 | dev_err(&pdev->dev, "Failed to allocate structure\n"); | 728 | return -ENOMEM; |
729 | ret = -ENOMEM; | 729 | |
730 | goto err; | ||
731 | } | ||
732 | global_dev = dev; | 730 | global_dev = dev; |
733 | dev->dev = &pdev->dev; | 731 | dev->dev = &pdev->dev; |
734 | 732 | ||
@@ -737,11 +735,10 @@ static int dcp_probe(struct platform_device *pdev) | |||
737 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 735 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
738 | if (!r) { | 736 | if (!r) { |
739 | dev_err(&pdev->dev, "failed to get IORESOURCE_MEM\n"); | 737 | dev_err(&pdev->dev, "failed to get IORESOURCE_MEM\n"); |
740 | ret = -ENXIO; | 738 | return -ENXIO; |
741 | goto err_dev; | ||
742 | } | 739 | } |
743 | dev->dcp_regs_base = ioremap(r->start, resource_size(r)); | 740 | dev->dcp_regs_base = devm_ioremap(&pdev->dev, r->start, |
744 | 741 | resource_size(r)); | |
745 | 742 | ||
746 | dcp_set(dev, DCP_CTRL_SFRST, DCP_REG_CTRL); | 743 | dcp_set(dev, DCP_CTRL_SFRST, DCP_REG_CTRL); |
747 | udelay(10); | 744 | udelay(10); |
@@ -762,15 +759,13 @@ static int dcp_probe(struct platform_device *pdev) | |||
762 | r = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 759 | r = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
763 | if (!r) { | 760 | if (!r) { |
764 | dev_err(&pdev->dev, "can't get IRQ resource (0)\n"); | 761 | dev_err(&pdev->dev, "can't get IRQ resource (0)\n"); |
765 | ret = -EIO; | 762 | return -EIO; |
766 | goto err_unmap_mem; | ||
767 | } | 763 | } |
768 | dev->dcp_vmi_irq = r->start; | 764 | dev->dcp_vmi_irq = r->start; |
769 | ret = request_irq(dev->dcp_vmi_irq, dcp_vmi_irq, 0, "dcp", dev); | 765 | ret = request_irq(dev->dcp_vmi_irq, dcp_vmi_irq, 0, "dcp", dev); |
770 | if (ret != 0) { | 766 | if (ret != 0) { |
771 | dev_err(&pdev->dev, "can't request_irq (0)\n"); | 767 | dev_err(&pdev->dev, "can't request_irq (0)\n"); |
772 | ret = -EIO; | 768 | return -EIO; |
773 | goto err_unmap_mem; | ||
774 | } | 769 | } |
775 | 770 | ||
776 | r = platform_get_resource(pdev, IORESOURCE_IRQ, 1); | 771 | r = platform_get_resource(pdev, IORESOURCE_IRQ, 1); |
@@ -863,11 +858,7 @@ err_free_irq1: | |||
863 | free_irq(dev->dcp_irq, dev); | 858 | free_irq(dev->dcp_irq, dev); |
864 | err_free_irq0: | 859 | err_free_irq0: |
865 | free_irq(dev->dcp_vmi_irq, dev); | 860 | free_irq(dev->dcp_vmi_irq, dev); |
866 | err_unmap_mem: | 861 | |
867 | iounmap((void *) dev->dcp_regs_base); | ||
868 | err_dev: | ||
869 | kfree(dev); | ||
870 | err: | ||
871 | return ret; | 862 | return ret; |
872 | } | 863 | } |
873 | 864 | ||
@@ -890,14 +881,11 @@ static int dcp_remove(struct platform_device *pdev) | |||
890 | tasklet_kill(&dev->done_task); | 881 | tasklet_kill(&dev->done_task); |
891 | tasklet_kill(&dev->queue_task); | 882 | tasklet_kill(&dev->queue_task); |
892 | 883 | ||
893 | iounmap((void *) dev->dcp_regs_base); | ||
894 | |||
895 | for (j = 0; j < ARRAY_SIZE(algs); j++) | 884 | for (j = 0; j < ARRAY_SIZE(algs); j++) |
896 | crypto_unregister_alg(&algs[j]); | 885 | crypto_unregister_alg(&algs[j]); |
897 | 886 | ||
898 | misc_deregister(&dev->dcp_bootstream_misc); | 887 | misc_deregister(&dev->dcp_bootstream_misc); |
899 | 888 | ||
900 | kfree(dev); | ||
901 | return 0; | 889 | return 0; |
902 | } | 890 | } |
903 | 891 | ||