drm/vkms: init plane using drmm_universal_plane_alloc

By using drmm_universal_plane_alloc instead of
drm_universal_plane_init, we let the DRM infrastructure handles
resource allocation and cleanup. We can also get rid of some
code repetitions for plane cleanup, improving code maintainability
in vkms.

Signed-off-by: Melissa Wen <melissa.srw@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/3bbdabed0274d2d0917d1b829dd16f13d7b495f5.1619250933.git.melissa.srw@gmail.com
This commit is contained in:
Melissa Wen
2021-04-24 05:23:27 -03:00
parent 19d327a31a
commit 2f56dd8c77
3 changed files with 22 additions and 34 deletions

View File

@@ -39,7 +39,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index)
struct drm_connector *connector = &output->connector;
struct drm_encoder *encoder = &output->encoder;
struct drm_crtc *crtc = &output->crtc;
struct drm_plane *primary, *cursor = NULL;
struct vkms_plane *primary, *cursor = NULL;
int ret;
int writeback;
@@ -49,15 +49,13 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index)
if (vkmsdev->config->cursor) {
cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, index);
if (IS_ERR(cursor)) {
ret = PTR_ERR(cursor);
goto err_cursor;
}
if (IS_ERR(cursor))
return PTR_ERR(cursor);
}
ret = vkms_crtc_init(dev, crtc, primary, cursor);
ret = vkms_crtc_init(dev, crtc, &primary->base, &cursor->base);
if (ret)
goto err_crtc;
return ret;
ret = drm_connector_init(dev, connector, &vkms_connector_funcs,
DRM_MODE_CONNECTOR_VIRTUAL);
@@ -100,12 +98,5 @@ err_encoder:
err_connector:
drm_crtc_cleanup(crtc);
err_crtc:
if (vkmsdev->config->cursor)
drm_plane_cleanup(cursor);
err_cursor:
drm_plane_cleanup(primary);
return ret;
}