Skip to content

Commit

Permalink
drm/virtio: use drmm_mode_config_init
Browse files Browse the repository at this point in the history
Use managed init call to simplify cleanup.

Signed-off-by: Gerd Hoffmann <[email protected]>
Reviewed-by: Gurchetan Singh <[email protected]>
Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
kraxel committed Sep 15, 2020
1 parent 37054fc commit d6005d3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
11 changes: 7 additions & 4 deletions drivers/gpu/drm/virtio/virtgpu_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,14 @@ static const struct drm_mode_config_funcs virtio_gpu_mode_funcs = {
.atomic_commit = drm_atomic_helper_commit,
};

void virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev)
int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev)
{
int i;
int i, ret;

ret = drmm_mode_config_init(vgdev->ddev);
if (ret)
return ret;

drm_mode_config_init(vgdev->ddev);
vgdev->ddev->mode_config.quirk_addfb_prefer_host_byte_order = true;
vgdev->ddev->mode_config.funcs = &virtio_gpu_mode_funcs;

Expand All @@ -343,6 +346,7 @@ void virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev)
vgdev_output_init(vgdev, i);

drm_mode_config_reset(vgdev->ddev);
return 0;
}

void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev)
Expand All @@ -351,5 +355,4 @@ void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev)

for (i = 0 ; i < vgdev->num_scanouts; ++i)
kfree(vgdev->outputs[i].edid);
drm_mode_config_cleanup(vgdev->ddev);
}
2 changes: 1 addition & 1 deletion drivers/gpu/drm/virtio/virtgpu_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ virtio_gpu_cmd_resource_assign_uuid(struct virtio_gpu_device *vgdev,
struct virtio_gpu_object_array *objs);

/* virtgpu_display.c */
void virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev);
int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev);
void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev);

/* virtgpu_plane.c */
Expand Down
6 changes: 5 additions & 1 deletion drivers/gpu/drm/virtio/virtgpu_kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ int virtio_gpu_init(struct drm_device *dev)
num_capsets, &num_capsets);
DRM_INFO("number of cap sets: %d\n", num_capsets);

virtio_gpu_modeset_init(vgdev);
ret = virtio_gpu_modeset_init(vgdev);
if (ret) {
DRM_ERROR("modeset init failed\n");
goto err_scanouts;
}

virtio_device_ready(vgdev->vdev);

Expand Down

0 comments on commit d6005d3

Please sign in to comment.