]> git.karo-electronics.de Git - linux-beck.git/commitdiff
iommu/omap: Convert to devm_* interfaces
authorSuman Anna <s-anna@ti.com>
Fri, 28 Feb 2014 20:42:32 +0000 (14:42 -0600)
committerJoerg Roedel <joro@8bytes.org>
Tue, 4 Mar 2014 16:00:58 +0000 (17:00 +0100)
Use the various devm_ interfaces to simplify the cleanup in
probe and remove functions.

Signed-off-by: Florian Vaussard <florian.vaussard@epfl.ch>
Signed-off-by: Suman Anna <s-anna@ti.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Joerg Roedel <joro@8bytes.org>
drivers/iommu/omap-iommu.c

index bcd78a720630782313f413d0db8a99adbd7e77da..fff2ffdc26f47a1ec9b31194a43437b1d869485f 100644 (file)
@@ -941,7 +941,7 @@ static int omap_iommu_probe(struct platform_device *pdev)
        struct resource *res;
        struct iommu_platform_data *pdata = pdev->dev.platform_data;
 
-       obj = kzalloc(sizeof(*obj) + MMU_REG_SIZE, GFP_KERNEL);
+       obj = devm_kzalloc(&pdev->dev, sizeof(*obj) + MMU_REG_SIZE, GFP_KERNEL);
        if (!obj)
                return -ENOMEM;
 
@@ -958,33 +958,18 @@ static int omap_iommu_probe(struct platform_device *pdev)
        INIT_LIST_HEAD(&obj->mmap);
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!res) {
-               err = -ENODEV;
-               goto err_mem;
-       }
-
-       res = request_mem_region(res->start, resource_size(res),
-                                dev_name(&pdev->dev));
-       if (!res) {
-               err = -EIO;
-               goto err_mem;
-       }
-
-       obj->regbase = ioremap(res->start, resource_size(res));
-       if (!obj->regbase) {
-               err = -ENOMEM;
-               goto err_ioremap;
-       }
+       obj->regbase = devm_ioremap_resource(obj->dev, res);
+       if (IS_ERR(obj->regbase))
+               return PTR_ERR(obj->regbase);
 
        irq = platform_get_irq(pdev, 0);
-       if (irq < 0) {
-               err = -ENODEV;
-               goto err_irq;
-       }
-       err = request_irq(irq, iommu_fault_handler, IRQF_SHARED,
-                         dev_name(&pdev->dev), obj);
+       if (irq < 0)
+               return -ENODEV;
+
+       err = devm_request_irq(obj->dev, irq, iommu_fault_handler, IRQF_SHARED,
+                              dev_name(obj->dev), obj);
        if (err < 0)
-               goto err_irq;
+               return err;
        platform_set_drvdata(pdev, obj);
 
        pm_runtime_irq_safe(obj->dev);
@@ -992,34 +977,17 @@ static int omap_iommu_probe(struct platform_device *pdev)
 
        dev_info(&pdev->dev, "%s registered\n", obj->name);
        return 0;
-
-err_irq:
-       iounmap(obj->regbase);
-err_ioremap:
-       release_mem_region(res->start, resource_size(res));
-err_mem:
-       kfree(obj);
-       return err;
 }
 
 static int omap_iommu_remove(struct platform_device *pdev)
 {
-       int irq;
-       struct resource *res;
        struct omap_iommu *obj = platform_get_drvdata(pdev);
 
        iopgtable_clear_entry_all(obj);
 
-       irq = platform_get_irq(pdev, 0);
-       free_irq(irq, obj);
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       release_mem_region(res->start, resource_size(res));
-       iounmap(obj->regbase);
-
        pm_runtime_disable(obj->dev);
 
        dev_info(&pdev->dev, "%s removed\n", obj->name);
-       kfree(obj);
        return 0;
 }