@@ -635,10 +635,12 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
a6xx_rpmh_stop(gmu);
err:
- if (!IS_ERR_OR_NULL(pdcptr))
- iounmap(pdcptr);
- if (!IS_ERR_OR_NULL(seqptr))
- iounmap(seqptr);
+ if (!IS_ERR_OR_NULL(pdcptr)){
+ return ERR_PTR(-EINVAL);
+ }
+ if (!IS_ERR_OR_NULL(seqptr)){
+ return ERR_PTR(-EINVAL);
+ }
}
/*
@@ -1503,7 +1505,7 @@ static void __iomem *a6xx_gmu_get_mmio(struct platform_device *pdev,
return ERR_PTR(-EINVAL);
}
- ret = ioremap(res->start, resource_size(res));
+ ret = devm_ioremap_resource(&pdev->dev, res);
if (!ret) {
DRM_DEV_ERROR(&pdev->dev, "Unable to map the %s registers\n", name);
return ERR_PTR(-EINVAL);
@@ -1613,13 +1615,13 @@ int a6xx_gmu_wrapper_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
gmu->mmio = a6xx_gmu_get_mmio(pdev, "gmu");
if (IS_ERR(gmu->mmio)) {
ret = PTR_ERR(gmu->mmio);
- goto err_mmio;
+ goto err_cleanup;
}
gmu->cxpd = dev_pm_domain_attach_by_name(gmu->dev, "cx");
if (IS_ERR(gmu->cxpd)) {
ret = PTR_ERR(gmu->cxpd);
- goto err_mmio;
+ goto err_cleanup;
}
if (!device_link_add(gmu->dev, gmu->cxpd, DL_FLAG_PM_RUNTIME)) {
@@ -1635,7 +1637,7 @@ int a6xx_gmu_wrapper_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
gmu->gxpd = dev_pm_domain_attach_by_name(gmu->dev, "gx");
if (IS_ERR(gmu->gxpd)) {
ret = PTR_ERR(gmu->gxpd);
- goto err_mmio;
+ goto err_cleanup;
}
gmu->initialized = true;
@@ -1645,9 +1647,7 @@ int a6xx_gmu_wrapper_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
detach_cxpd:
dev_pm_domain_detach(gmu->cxpd, false);
-err_mmio:
- iounmap(gmu->mmio);
-
+err_cleanup:
/* Drop reference taken in of_find_device_by_node */
put_device(gmu->dev);
@@ -1762,7 +1762,7 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
gmu->rscc = a6xx_gmu_get_mmio(pdev, "rscc");
if (IS_ERR(gmu->rscc)) {
ret = -ENODEV;
- goto err_mmio;
+ goto err_cleanup;
}
} else {
gmu->rscc = gmu->mmio + 0x23000;
@@ -1774,13 +1774,13 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
if (gmu->hfi_irq < 0 || gmu->gmu_irq < 0) {
ret = -ENODEV;
- goto err_mmio;
+ goto err_cleanup;
}
gmu->cxpd = dev_pm_domain_attach_by_name(gmu->dev, "cx");
if (IS_ERR(gmu->cxpd)) {
ret = PTR_ERR(gmu->cxpd);
- goto err_mmio;
+ goto err_cleanup;
}
link = device_link_add(gmu->dev, gmu->cxpd, DL_FLAG_PM_RUNTIME);
@@ -1824,10 +1824,7 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
detach_cxpd:
dev_pm_domain_detach(gmu->cxpd, false);
-err_mmio:
- iounmap(gmu->mmio);
- if (platform_get_resource_byname(pdev, IORESOURCE_MEM, "rscc"))
- iounmap(gmu->rscc);
+err_cleanup:
free_irq(gmu->gmu_irq, gmu);
free_irq(gmu->hfi_irq, gmu);