Commit ae95c46d authored by Dmitry Osipenko's avatar Dmitry Osipenko Committed by Joerg Roedel

iommu/tegra: gart: Clean up driver probe errors handling

Properly clean up allocated resources on the drivers probe failure and
remove unneeded checks.
Signed-off-by: default avatarDmitry Osipenko <digetx@gmail.com>
Acked-by: default avatarThierry Reding <treding@nvidia.com>
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 4f821c10
...@@ -411,9 +411,6 @@ static int tegra_gart_probe(struct platform_device *pdev) ...@@ -411,9 +411,6 @@ static int tegra_gart_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int ret; int ret;
if (gart_handle)
return -EIO;
BUILD_BUG_ON(PAGE_SHIFT != GART_PAGE_SHIFT); BUILD_BUG_ON(PAGE_SHIFT != GART_PAGE_SHIFT);
/* the GART memory aperture is required */ /* the GART memory aperture is required */
...@@ -448,8 +445,7 @@ static int tegra_gart_probe(struct platform_device *pdev) ...@@ -448,8 +445,7 @@ static int tegra_gart_probe(struct platform_device *pdev)
ret = iommu_device_register(&gart->iommu); ret = iommu_device_register(&gart->iommu);
if (ret) { if (ret) {
dev_err(dev, "Failed to register IOMMU\n"); dev_err(dev, "Failed to register IOMMU\n");
iommu_device_sysfs_remove(&gart->iommu); goto remove_sysfs;
return ret;
} }
gart->dev = &pdev->dev; gart->dev = &pdev->dev;
...@@ -463,7 +459,8 @@ static int tegra_gart_probe(struct platform_device *pdev) ...@@ -463,7 +459,8 @@ static int tegra_gart_probe(struct platform_device *pdev)
gart->savedata = vmalloc(array_size(sizeof(u32), gart->page_count)); gart->savedata = vmalloc(array_size(sizeof(u32), gart->page_count));
if (!gart->savedata) { if (!gart->savedata) {
dev_err(dev, "failed to allocate context save area\n"); dev_err(dev, "failed to allocate context save area\n");
return -ENOMEM; ret = -ENOMEM;
goto unregister_iommu;
} }
platform_set_drvdata(pdev, gart); platform_set_drvdata(pdev, gart);
...@@ -472,6 +469,13 @@ static int tegra_gart_probe(struct platform_device *pdev) ...@@ -472,6 +469,13 @@ static int tegra_gart_probe(struct platform_device *pdev)
gart_handle = gart; gart_handle = gart;
return 0; return 0;
unregister_iommu:
iommu_device_unregister(&gart->iommu);
remove_sysfs:
iommu_device_sysfs_remove(&gart->iommu);
return ret;
} }
static const struct dev_pm_ops tegra_gart_pm_ops = { static const struct dev_pm_ops tegra_gart_pm_ops = {
......
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