drm/vc4: Use devm_drm_dev_alloc
We can simplify a bit the bind code, its error path and unbind by using the managed devm_drm_dev_alloc function. Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Maxime Ripard <maxime@cerno.tech> Link: https://patchwork.freedesktop.org/patch/msgid/20201029190104.2181730-5-maxime@cerno.tech
This commit is contained in:
@@ -257,41 +257,37 @@ static int vc4_drm_bind(struct device *dev)
|
||||
|
||||
dev->coherent_dma_mask = DMA_BIT_MASK(32);
|
||||
|
||||
vc4 = devm_kzalloc(dev, sizeof(*vc4), GFP_KERNEL);
|
||||
if (!vc4)
|
||||
return -ENOMEM;
|
||||
|
||||
/* If VC4 V3D is missing, don't advertise render nodes. */
|
||||
node = of_find_matching_node_and_match(NULL, vc4_v3d_dt_match, NULL);
|
||||
if (!node || !of_device_is_available(node))
|
||||
vc4_drm_driver.driver_features &= ~DRIVER_RENDER;
|
||||
of_node_put(node);
|
||||
|
||||
drm = drm_dev_alloc(&vc4_drm_driver, dev);
|
||||
if (IS_ERR(drm))
|
||||
return PTR_ERR(drm);
|
||||
vc4 = devm_drm_dev_alloc(dev, &vc4_drm_driver, struct vc4_dev, base);
|
||||
if (IS_ERR(vc4))
|
||||
return PTR_ERR(vc4);
|
||||
|
||||
drm = &vc4->base;
|
||||
platform_set_drvdata(pdev, drm);
|
||||
vc4->dev = drm;
|
||||
drm->dev_private = vc4;
|
||||
INIT_LIST_HEAD(&vc4->debugfs_list);
|
||||
|
||||
mutex_init(&vc4->bin_bo_lock);
|
||||
|
||||
ret = vc4_bo_cache_init(drm);
|
||||
if (ret)
|
||||
goto dev_put;
|
||||
return ret;
|
||||
|
||||
ret = drmm_mode_config_init(drm);
|
||||
if (ret)
|
||||
goto dev_put;
|
||||
return ret;
|
||||
|
||||
ret = vc4_gem_init(drm);
|
||||
if (ret)
|
||||
goto dev_put;
|
||||
return ret;
|
||||
|
||||
ret = component_bind_all(dev, drm);
|
||||
if (ret)
|
||||
goto dev_put;
|
||||
return ret;
|
||||
|
||||
ret = vc4_plane_create_additional_planes(drm);
|
||||
if (ret)
|
||||
@@ -316,8 +312,7 @@ static int vc4_drm_bind(struct device *dev)
|
||||
|
||||
unbind_all:
|
||||
component_unbind_all(dev, drm);
|
||||
dev_put:
|
||||
drm_dev_put(drm);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -332,8 +327,6 @@ static void vc4_drm_unbind(struct device *dev)
|
||||
|
||||
drm_atomic_private_obj_fini(&vc4->load_tracker);
|
||||
drm_atomic_private_obj_fini(&vc4->ctm_manager);
|
||||
|
||||
drm_dev_put(drm);
|
||||
}
|
||||
|
||||
static const struct component_master_ops vc4_drm_ops = {
|
||||
|
Reference in New Issue
Block a user