]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/v3d: Use devm_drm_dev_alloc
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 15 Apr 2020 07:39:43 +0000 (09:39 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 28 Apr 2020 13:15:46 +0000 (15:15 +0200)
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
drivers/gpu/drm/v3d/v3d_drv.c

index ead62a15d48f694d799a1d02b4b105ad15d3c9f5..f57d408ef37132c2b73ea28bb25a9cb3c878a9a2 100644 (file)
@@ -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;