crypto: ccp - Convert calls to their devm_ counterparts
authorTom Lendacky <thomas.lendacky@amd.com>
Tue, 3 Feb 2015 19:07:23 +0000 (13:07 -0600)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 27 Feb 2015 09:48:48 +0000 (22:48 +1300)
Where applicable, convert calls to their devm_ counterparts, e.g. kzalloc
to devm_kzalloc.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/ccp/ccp-dev.c
drivers/crypto/ccp/ccp-pci.c
drivers/crypto/ccp/ccp-platform.c

index 68c637af2c4204c242ef3773d578927ef6455b0a..861bacc1bb94fb79d4147dec386020ad13282ce8 100644 (file)
@@ -295,7 +295,7 @@ struct ccp_device *ccp_alloc_struct(struct device *dev)
 {
        struct ccp_device *ccp;
 
-       ccp = kzalloc(sizeof(*ccp), GFP_KERNEL);
+       ccp = devm_kzalloc(dev, sizeof(*ccp), GFP_KERNEL);
        if (!ccp)
                return NULL;
        ccp->dev = dev;
index 1980f77c29ef9f2f8d83ef360250b6249ad68de1..af190d4795a89df056483485992c0661f79fd2da 100644 (file)
@@ -174,11 +174,10 @@ static int ccp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        if (!ccp)
                goto e_err;
 
-       ccp_pci = kzalloc(sizeof(*ccp_pci), GFP_KERNEL);
-       if (!ccp_pci) {
-               ret = -ENOMEM;
-               goto e_free1;
-       }
+       ccp_pci = devm_kzalloc(dev, sizeof(*ccp_pci), GFP_KERNEL);
+       if (!ccp_pci)
+               goto e_err;
+
        ccp->dev_specific = ccp_pci;
        ccp->get_irq = ccp_get_irqs;
        ccp->free_irq = ccp_free_irqs;
@@ -186,7 +185,7 @@ static int ccp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        ret = pci_request_regions(pdev, "ccp");
        if (ret) {
                dev_err(dev, "pci_request_regions failed (%d)\n", ret);
-               goto e_free2;
+               goto e_err;
        }
 
        ret = pci_enable_device(pdev);
@@ -239,12 +238,6 @@ e_device:
 e_regions:
        pci_release_regions(pdev);
 
-e_free2:
-       kfree(ccp_pci);
-
-e_free1:
-       kfree(ccp);
-
 e_err:
        dev_notice(dev, "initialization failed\n");
        return ret;
@@ -266,8 +259,6 @@ static void ccp_pci_remove(struct pci_dev *pdev)
 
        pci_release_regions(pdev);
 
-       kfree(ccp);
-
        dev_notice(dev, "disabled\n");
 }
 
index 04265a3c36085b96e92d182a4ffdb0fc20a600cc..20661f099198b483b65f15adf4f409ba5c549a5f 100644 (file)
@@ -103,7 +103,7 @@ static int ccp_platform_probe(struct platform_device *pdev)
        ccp->io_map = devm_ioremap_resource(dev, ior);
        if (IS_ERR(ccp->io_map)) {
                ret = PTR_ERR(ccp->io_map);
-               goto e_free;
+               goto e_err;
        }
        ccp->io_regs = ccp->io_map;
 
@@ -112,7 +112,7 @@ static int ccp_platform_probe(struct platform_device *pdev)
        ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
        if (ret) {
                dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n", ret);
-               goto e_free;
+               goto e_err;
        }
 
        if (of_property_read_bool(dev->of_node, "dma-coherent"))
@@ -124,15 +124,12 @@ static int ccp_platform_probe(struct platform_device *pdev)
 
        ret = ccp_init(ccp);
        if (ret)
-               goto e_free;
+               goto e_err;
 
        dev_notice(dev, "enabled\n");
 
        return 0;
 
-e_free:
-       kfree(ccp);
-
 e_err:
        dev_notice(dev, "initialization failed\n");
        return ret;
@@ -145,8 +142,6 @@ static int ccp_platform_remove(struct platform_device *pdev)
 
        ccp_destroy(ccp);
 
-       kfree(ccp);
-
        dev_notice(dev, "disabled\n");
 
        return 0;