mirror of
https://github.com/torvalds/linux.git
synced 2024-11-07 20:51:47 +00:00
iommu/omap: Convert to devm_* interfaces
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>
This commit is contained in:
parent
0414855fdc
commit
f129b3dfb5
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user