提交 f129b3df 编写于 作者: S Suman Anna 提交者: Joerg Roedel

iommu/omap: Convert to devm_* interfaces

Use the various devm_ interfaces to simplify the cleanup in
probe and remove functions.
Signed-off-by: NFlorian Vaussard <florian.vaussard@epfl.ch>
Signed-off-by: NSuman Anna <s-anna@ti.com>
Acked-by: NLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: NJoerg Roedel <joro@8bytes.org>
上级 0414855f
...@@ -941,7 +941,7 @@ static int omap_iommu_probe(struct platform_device *pdev) ...@@ -941,7 +941,7 @@ static int omap_iommu_probe(struct platform_device *pdev)
struct resource *res; struct resource *res;
struct iommu_platform_data *pdata = pdev->dev.platform_data; 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) if (!obj)
return -ENOMEM; return -ENOMEM;
...@@ -958,33 +958,18 @@ static int omap_iommu_probe(struct platform_device *pdev) ...@@ -958,33 +958,18 @@ static int omap_iommu_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&obj->mmap); INIT_LIST_HEAD(&obj->mmap);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { obj->regbase = devm_ioremap_resource(obj->dev, res);
err = -ENODEV; if (IS_ERR(obj->regbase))
goto err_mem; return PTR_ERR(obj->regbase);
}
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;
}
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0)
err = -ENODEV; return -ENODEV;
goto err_irq;
} err = devm_request_irq(obj->dev, irq, iommu_fault_handler, IRQF_SHARED,
err = request_irq(irq, iommu_fault_handler, IRQF_SHARED, dev_name(obj->dev), obj);
dev_name(&pdev->dev), obj);
if (err < 0) if (err < 0)
goto err_irq; return err;
platform_set_drvdata(pdev, obj); platform_set_drvdata(pdev, obj);
pm_runtime_irq_safe(obj->dev); pm_runtime_irq_safe(obj->dev);
...@@ -992,34 +977,17 @@ static int omap_iommu_probe(struct platform_device *pdev) ...@@ -992,34 +977,17 @@ static int omap_iommu_probe(struct platform_device *pdev)
dev_info(&pdev->dev, "%s registered\n", obj->name); dev_info(&pdev->dev, "%s registered\n", obj->name);
return 0; 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) static int omap_iommu_remove(struct platform_device *pdev)
{ {
int irq;
struct resource *res;
struct omap_iommu *obj = platform_get_drvdata(pdev); struct omap_iommu *obj = platform_get_drvdata(pdev);
iopgtable_clear_entry_all(obj); 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); pm_runtime_disable(obj->dev);
dev_info(&pdev->dev, "%s removed\n", obj->name); dev_info(&pdev->dev, "%s removed\n", obj->name);
kfree(obj);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册