Commit 46c16d1e authored by Cho KyongHo's avatar Cho KyongHo Committed by Joerg Roedel

iommu/exynos: Use managed device helper functions

This patch uses managed device helper functions in the probe().
Signed-off-by: default avatarCho KyongHo <pullip.cho@samsung.com>
Signed-off-by: default avatarShaik Ameer Basha <shaik.ameer@samsung.com>
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent e5cf63c3
...@@ -343,7 +343,6 @@ static bool __exynos_sysmmu_disable(struct sysmmu_drvdata *data) ...@@ -343,7 +343,6 @@ static bool __exynos_sysmmu_disable(struct sysmmu_drvdata *data)
__raw_writel(CTRL_DISABLE, data->sfrbase + REG_MMU_CTRL); __raw_writel(CTRL_DISABLE, data->sfrbase + REG_MMU_CTRL);
if (!IS_ERR(data->clk))
clk_disable(data->clk); clk_disable(data->clk);
disabled = true; disabled = true;
...@@ -387,7 +386,6 @@ static int __exynos_sysmmu_enable(struct sysmmu_drvdata *data, ...@@ -387,7 +386,6 @@ static int __exynos_sysmmu_enable(struct sysmmu_drvdata *data,
goto finish; goto finish;
} }
if (!IS_ERR(data->clk))
clk_enable(data->clk); clk_enable(data->clk);
data->pgtable = pgtable; data->pgtable = pgtable;
...@@ -499,49 +497,43 @@ void exynos_sysmmu_tlb_invalidate(struct device *dev) ...@@ -499,49 +497,43 @@ void exynos_sysmmu_tlb_invalidate(struct device *dev)
static int exynos_sysmmu_probe(struct platform_device *pdev) static int exynos_sysmmu_probe(struct platform_device *pdev)
{ {
int ret; int irq, ret;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct sysmmu_drvdata *data; struct sysmmu_drvdata *data;
struct resource *res; struct resource *res;
data = kzalloc(sizeof(*data), GFP_KERNEL); data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data) { if (!data)
dev_dbg(dev, "Not enough memory\n"); return -ENOMEM;
ret = -ENOMEM;
goto err_alloc;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { data->sfrbase = devm_ioremap_resource(dev, res);
dev_dbg(dev, "Unable to find IOMEM region\n"); if (IS_ERR(data->sfrbase))
ret = -ENOENT; return PTR_ERR(data->sfrbase);
goto err_init;
}
data->sfrbase = ioremap(res->start, resource_size(res));
if (!data->sfrbase) {
dev_dbg(dev, "Unable to map IOMEM @ PA:%#x\n", res->start);
ret = -ENOENT;
goto err_res;
}
ret = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (ret <= 0) { if (irq <= 0) {
dev_dbg(dev, "Unable to find IRQ resource\n"); dev_dbg(dev, "Unable to find IRQ resource\n");
goto err_irq; return irq;
} }
ret = request_irq(ret, exynos_sysmmu_irq, 0, ret = devm_request_irq(dev, irq, exynos_sysmmu_irq, 0,
dev_name(dev), data); dev_name(dev), data);
if (ret) { if (ret) {
dev_dbg(dev, "Unabled to register interrupt handler\n"); dev_err(dev, "Unabled to register handler of irq %d\n", irq);
goto err_irq; return ret;
} }
if (dev_get_platdata(dev)) { data->clk = devm_clk_get(dev, "sysmmu");
data->clk = clk_get(dev, "sysmmu"); if (IS_ERR(data->clk)) {
if (IS_ERR(data->clk)) dev_err(dev, "Failed to get clock!\n");
dev_dbg(dev, "No clock descriptor registered\n"); return PTR_ERR(data->clk);
} else {
ret = clk_prepare(data->clk);
if (ret) {
dev_err(dev, "Failed to prepare clk\n");
return ret;
}
} }
data->sysmmu = dev; data->sysmmu = dev;
...@@ -554,17 +546,7 @@ static int exynos_sysmmu_probe(struct platform_device *pdev) ...@@ -554,17 +546,7 @@ static int exynos_sysmmu_probe(struct platform_device *pdev)
pm_runtime_enable(dev); pm_runtime_enable(dev);
dev_dbg(dev, "Initialized\n");
return 0; return 0;
err_irq:
free_irq(platform_get_irq(pdev, 0), data);
err_res:
iounmap(data->sfrbase);
err_init:
kfree(data);
err_alloc:
dev_err(dev, "Failed to initialize\n");
return ret;
} }
static struct platform_driver exynos_sysmmu_driver = { static struct platform_driver exynos_sysmmu_driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment