drm/v3d: Use devm_drm_dev_alloc
Also allows us to simplify the unroll code since the drm_dev_put disappears. Acked-by: Eric Anholt <eric@anholt.net> Signed-off-by: Daniel 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
This commit is contained in:
parent
af25c16bd1
commit
235b7e7d7e
@ -251,29 +251,23 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
|
||||
u32 ident1;
|
||||
|
||||
|
||||
v3d = kzalloc(sizeof(*v3d), GFP_KERNEL);
|
||||
if (!v3d)
|
||||
return -ENOMEM;
|
||||
v3d = devm_drm_dev_alloc(dev, &v3d_drm_driver, struct v3d_dev, drm);
|
||||
if (IS_ERR(v3d))
|
||||
return PTR_ERR(v3d);
|
||||
|
||||
v3d->dev = dev;
|
||||
v3d->pdev = pdev;
|
||||
drm = &v3d->drm;
|
||||
|
||||
ret = drm_dev_init(&v3d->drm, &v3d_drm_driver, dev);
|
||||
if (ret) {
|
||||
kfree(v3d);
|
||||
return ret;
|
||||
}
|
||||
|
||||
platform_set_drvdata(pdev, drm);
|
||||
drmm_add_final_kfree(drm, v3d);
|
||||
|
||||
ret = map_regs(v3d, &v3d->hub_regs, "hub");
|
||||
if (ret)
|
||||
goto dev_destroy;
|
||||
return ret;
|
||||
|
||||
ret = map_regs(v3d, &v3d->core_regs[0], "core0");
|
||||
if (ret)
|
||||
goto dev_destroy;
|
||||
return ret;
|
||||
|
||||
mmu_debug = V3D_READ(V3D_MMU_DEBUG_INFO);
|
||||
dev->coherent_dma_mask =
|
||||
@ -291,29 +285,28 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
|
||||
ret = PTR_ERR(v3d->reset);
|
||||
|
||||
if (ret == -EPROBE_DEFER)
|
||||
goto dev_destroy;
|
||||
return ret;
|
||||
|
||||
v3d->reset = NULL;
|
||||
ret = map_regs(v3d, &v3d->bridge_regs, "bridge");
|
||||
if (ret) {
|
||||
dev_err(dev,
|
||||
"Failed to get reset control or bridge regs\n");
|
||||
goto dev_destroy;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (v3d->ver < 41) {
|
||||
ret = map_regs(v3d, &v3d->gca_regs, "gca");
|
||||
if (ret)
|
||||
goto dev_destroy;
|
||||
return ret;
|
||||
}
|
||||
|
||||
v3d->mmu_scratch = dma_alloc_wc(dev, 4096, &v3d->mmu_scratch_paddr,
|
||||
GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO);
|
||||
if (!v3d->mmu_scratch) {
|
||||
dev_err(dev, "Failed to allocate MMU scratch page\n");
|
||||
ret = -ENOMEM;
|
||||
goto dev_destroy;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
pm_runtime_use_autosuspend(dev);
|
||||
@ -340,8 +333,6 @@ gem_destroy:
|
||||
v3d_gem_destroy(drm);
|
||||
dma_free:
|
||||
dma_free_wc(dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr);
|
||||
dev_destroy:
|
||||
drm_dev_put(drm);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -354,8 +345,6 @@ static int v3d_platform_drm_remove(struct platform_device *pdev)
|
||||
|
||||
v3d_gem_destroy(drm);
|
||||
|
||||
drm_dev_put(drm);
|
||||
|
||||
dma_free_wc(v3d->dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr);
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user