Commit 235b7e7d authored by Daniel Vetter's avatar Daniel Vetter

drm/v3d: Use devm_drm_dev_alloc

Also allows us to simplify the unroll code since the drm_dev_put
disappears.
Acked-by: default avatarEric Anholt <eric@anholt.net>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Cc: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20200415074034.175360-9-daniel.vetter@ffwll.ch
parent af25c16b
...@@ -251,29 +251,23 @@ static int v3d_platform_drm_probe(struct platform_device *pdev) ...@@ -251,29 +251,23 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
u32 ident1; u32 ident1;
v3d = kzalloc(sizeof(*v3d), GFP_KERNEL); v3d = devm_drm_dev_alloc(dev, &v3d_drm_driver, struct v3d_dev, drm);
if (!v3d) if (IS_ERR(v3d))
return -ENOMEM; return PTR_ERR(v3d);
v3d->dev = dev; v3d->dev = dev;
v3d->pdev = pdev; v3d->pdev = pdev;
drm = &v3d->drm; drm = &v3d->drm;
ret = drm_dev_init(&v3d->drm, &v3d_drm_driver, dev);
if (ret) {
kfree(v3d);
return ret;
}
platform_set_drvdata(pdev, drm); platform_set_drvdata(pdev, drm);
drmm_add_final_kfree(drm, v3d);
ret = map_regs(v3d, &v3d->hub_regs, "hub"); ret = map_regs(v3d, &v3d->hub_regs, "hub");
if (ret) if (ret)
goto dev_destroy; return ret;
ret = map_regs(v3d, &v3d->core_regs[0], "core0"); ret = map_regs(v3d, &v3d->core_regs[0], "core0");
if (ret) if (ret)
goto dev_destroy; return ret;
mmu_debug = V3D_READ(V3D_MMU_DEBUG_INFO); mmu_debug = V3D_READ(V3D_MMU_DEBUG_INFO);
dev->coherent_dma_mask = dev->coherent_dma_mask =
...@@ -291,29 +285,28 @@ static int v3d_platform_drm_probe(struct platform_device *pdev) ...@@ -291,29 +285,28 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
ret = PTR_ERR(v3d->reset); ret = PTR_ERR(v3d->reset);
if (ret == -EPROBE_DEFER) if (ret == -EPROBE_DEFER)
goto dev_destroy; return ret;
v3d->reset = NULL; v3d->reset = NULL;
ret = map_regs(v3d, &v3d->bridge_regs, "bridge"); ret = map_regs(v3d, &v3d->bridge_regs, "bridge");
if (ret) { if (ret) {
dev_err(dev, dev_err(dev,
"Failed to get reset control or bridge regs\n"); "Failed to get reset control or bridge regs\n");
goto dev_destroy; return ret;
} }
} }
if (v3d->ver < 41) { if (v3d->ver < 41) {
ret = map_regs(v3d, &v3d->gca_regs, "gca"); ret = map_regs(v3d, &v3d->gca_regs, "gca");
if (ret) if (ret)
goto dev_destroy; return ret;
} }
v3d->mmu_scratch = dma_alloc_wc(dev, 4096, &v3d->mmu_scratch_paddr, v3d->mmu_scratch = dma_alloc_wc(dev, 4096, &v3d->mmu_scratch_paddr,
GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO); GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO);
if (!v3d->mmu_scratch) { if (!v3d->mmu_scratch) {
dev_err(dev, "Failed to allocate MMU scratch page\n"); dev_err(dev, "Failed to allocate MMU scratch page\n");
ret = -ENOMEM; return -ENOMEM;
goto dev_destroy;
} }
pm_runtime_use_autosuspend(dev); pm_runtime_use_autosuspend(dev);
...@@ -340,8 +333,6 @@ static int v3d_platform_drm_probe(struct platform_device *pdev) ...@@ -340,8 +333,6 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
v3d_gem_destroy(drm); v3d_gem_destroy(drm);
dma_free: dma_free:
dma_free_wc(dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr); dma_free_wc(dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr);
dev_destroy:
drm_dev_put(drm);
return ret; return ret;
} }
...@@ -354,8 +345,6 @@ static int v3d_platform_drm_remove(struct platform_device *pdev) ...@@ -354,8 +345,6 @@ static int v3d_platform_drm_remove(struct platform_device *pdev)
v3d_gem_destroy(drm); v3d_gem_destroy(drm);
drm_dev_put(drm);
dma_free_wc(v3d->dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr); dma_free_wc(v3d->dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr);
return 0; return 0;
......
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