drm: use dev_name as default unique name in drm_dev_alloc()
authorNicolas Iooss <nicolas.iooss_linux@m4x.org>
Fri, 11 Dec 2015 10:20:28 +0000 (11:20 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 15 Dec 2015 12:56:06 +0000 (13:56 +0100)
The following code pattern exists in some DRM drivers:

    ddev = drm_dev_alloc(&driver, parent_dev);
    drm_dev_set_unique(ddev, dev_name(parent_dev));

(Sometimes dev_name(ddev->dev) is used, which is the same.)

As suggested in
http://lists.freedesktop.org/archives/dri-devel/2015-December/096441.html,
the unique name of a new DRM device can be set as dev_name(parent_dev)
when parent_dev is not NULL (vgem is a special case).

Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
drivers/gpu/drm/drm_drv.c
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
drivers/gpu/drm/nouveau/nouveau_drm.c
drivers/gpu/drm/rockchip/rockchip_drm_drv.c
drivers/gpu/drm/tegra/drm.c
drivers/gpu/drm/vc4/vc4_drv.c

index bf64380d8d56acca3c436e887a4facedd28bd569..a45b32ba029ed412a1451c1536b57306beb7f59b 100644 (file)
@@ -738,10 +738,6 @@ static int atmel_hlcdc_dc_drm_probe(struct platform_device *pdev)
        if (!ddev)
                return -ENOMEM;
 
-       ret = drm_dev_set_unique(ddev, dev_name(ddev->dev));
-       if (ret)
-               goto err_unref;
-
        ret = atmel_hlcdc_dc_load(ddev);
        if (ret)
                goto err_unref;
index eaa4316f3c453d4b2e8dd02d281562d115b6f781..bf934cdea21c9b277c5b8f2ee6cc75581c9f1a3a 100644 (file)
@@ -633,8 +633,17 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
                }
        }
 
+       if (parent) {
+               ret = drm_dev_set_unique(dev, dev_name(parent));
+               if (ret)
+                       goto err_setunique;
+       }
+
        return dev;
 
+err_setunique:
+       if (drm_core_check_feature(dev, DRIVER_GEM))
+               drm_gem_destroy(dev);
 err_ctxbitmap:
        drm_legacy_ctxbitmap_cleanup(dev);
        drm_ht_remove(&dev->map_hash);
index 1930234ba5f13596f3b998d737c88e987b3370e7..fca97d3fc84666b5d96b7f34194dd46b35946d37 100644 (file)
@@ -363,7 +363,6 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev)
        fsl_dev->np = dev->of_node;
        drm->dev_private = fsl_dev;
        dev_set_drvdata(dev, fsl_dev);
-       drm_dev_set_unique(drm, dev_name(dev));
 
        ret = drm_dev_register(drm, 0);
        if (ret < 0)
index 2d23f95f17ce8bc2e82099138c04d029c07544ab..b3a563c44bcd51a2bd440b3d1318f7144897f383 100644 (file)
@@ -1046,10 +1046,6 @@ nouveau_platform_device_create(const struct nvkm_device_tegra_func *func,
                goto err_free;
        }
 
-       err = drm_dev_set_unique(drm, dev_name(&pdev->dev));
-       if (err < 0)
-               goto err_free;
-
        drm->platformdev = pdev;
        platform_set_drvdata(pdev, drm);
 
index 215d6c44af55b4a70863a0e08b67a4caa59ab12f..afbb7407c44f8110b7c70e80c4b6f0b370d62d4d 100644 (file)
@@ -450,10 +450,6 @@ static int rockchip_drm_bind(struct device *dev)
        if (!drm)
                return -ENOMEM;
 
-       ret = drm_dev_set_unique(drm, dev_name(dev));
-       if (ret)
-               goto err_free;
-
        ret = drm_dev_register(drm, 0);
        if (ret)
                goto err_free;
index e0f827790a5ee0a645b45bdd08b96f4d3a7496c1..ff948d27d118da96d2f061b969bec579a473c038 100644 (file)
@@ -991,7 +991,6 @@ static int host1x_drm_probe(struct host1x_device *dev)
        if (!drm)
                return -ENOMEM;
 
-       drm_dev_set_unique(drm, dev_name(&dev->dev));
        dev_set_drvdata(&dev->dev, drm);
 
        err = drm_dev_register(drm, 0);
index cbcbbb83500e30ff50874ae4a3ea8cc54086f76b..f1655fff8425166e88537c2b700c61de9200509d 100644 (file)
@@ -184,8 +184,6 @@ static int vc4_drm_bind(struct device *dev)
        vc4->dev = drm;
        drm->dev_private = vc4;
 
-       drm_dev_set_unique(drm, dev_name(dev));
-
        vc4_bo_cache_init(drm);
 
        drm_mode_config_init(drm);