Commit e112e593 authored by Nicolas Iooss's avatar Nicolas Iooss Committed by Daniel Vetter

drm: use dev_name as default unique name in drm_dev_alloc()

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: default avatarNicolas Iooss <nicolas.iooss_linux@m4x.org>
Acked-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 399368aa
...@@ -738,10 +738,6 @@ static int atmel_hlcdc_dc_drm_probe(struct platform_device *pdev) ...@@ -738,10 +738,6 @@ static int atmel_hlcdc_dc_drm_probe(struct platform_device *pdev)
if (!ddev) if (!ddev)
return -ENOMEM; return -ENOMEM;
ret = drm_dev_set_unique(ddev, dev_name(ddev->dev));
if (ret)
goto err_unref;
ret = atmel_hlcdc_dc_load(ddev); ret = atmel_hlcdc_dc_load(ddev);
if (ret) if (ret)
goto err_unref; goto err_unref;
......
...@@ -633,8 +633,17 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver, ...@@ -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; return dev;
err_setunique:
if (drm_core_check_feature(dev, DRIVER_GEM))
drm_gem_destroy(dev);
err_ctxbitmap: err_ctxbitmap:
drm_legacy_ctxbitmap_cleanup(dev); drm_legacy_ctxbitmap_cleanup(dev);
drm_ht_remove(&dev->map_hash); drm_ht_remove(&dev->map_hash);
......
...@@ -363,7 +363,6 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev) ...@@ -363,7 +363,6 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev)
fsl_dev->np = dev->of_node; fsl_dev->np = dev->of_node;
drm->dev_private = fsl_dev; drm->dev_private = fsl_dev;
dev_set_drvdata(dev, fsl_dev); dev_set_drvdata(dev, fsl_dev);
drm_dev_set_unique(drm, dev_name(dev));
ret = drm_dev_register(drm, 0); ret = drm_dev_register(drm, 0);
if (ret < 0) if (ret < 0)
......
...@@ -1046,10 +1046,6 @@ nouveau_platform_device_create(const struct nvkm_device_tegra_func *func, ...@@ -1046,10 +1046,6 @@ nouveau_platform_device_create(const struct nvkm_device_tegra_func *func,
goto err_free; goto err_free;
} }
err = drm_dev_set_unique(drm, dev_name(&pdev->dev));
if (err < 0)
goto err_free;
drm->platformdev = pdev; drm->platformdev = pdev;
platform_set_drvdata(pdev, drm); platform_set_drvdata(pdev, drm);
......
...@@ -450,10 +450,6 @@ static int rockchip_drm_bind(struct device *dev) ...@@ -450,10 +450,6 @@ static int rockchip_drm_bind(struct device *dev)
if (!drm) if (!drm)
return -ENOMEM; return -ENOMEM;
ret = drm_dev_set_unique(drm, dev_name(dev));
if (ret)
goto err_free;
ret = drm_dev_register(drm, 0); ret = drm_dev_register(drm, 0);
if (ret) if (ret)
goto err_free; goto err_free;
......
...@@ -991,7 +991,6 @@ static int host1x_drm_probe(struct host1x_device *dev) ...@@ -991,7 +991,6 @@ static int host1x_drm_probe(struct host1x_device *dev)
if (!drm) if (!drm)
return -ENOMEM; return -ENOMEM;
drm_dev_set_unique(drm, dev_name(&dev->dev));
dev_set_drvdata(&dev->dev, drm); dev_set_drvdata(&dev->dev, drm);
err = drm_dev_register(drm, 0); err = drm_dev_register(drm, 0);
......
...@@ -184,8 +184,6 @@ static int vc4_drm_bind(struct device *dev) ...@@ -184,8 +184,6 @@ static int vc4_drm_bind(struct device *dev)
vc4->dev = drm; vc4->dev = drm;
drm->dev_private = vc4; drm->dev_private = vc4;
drm_dev_set_unique(drm, dev_name(dev));
vc4_bo_cache_init(drm); vc4_bo_cache_init(drm);
drm_mode_config_init(drm); drm_mode_config_init(drm);
......
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