@@ -611,24 +611,12 @@ vmw_du_crtc_duplicate_state(struct drm_crtc *crtc)
*/
void vmw_du_crtc_reset(struct drm_crtc *crtc)
{
- struct vmw_crtc_state *vcs;
-
-
- if (crtc->state) {
- __drm_atomic_helper_crtc_destroy_state(crtc->state);
-
- kfree(vmw_crtc_state_to_vcs(crtc->state));
- }
+ struct vmw_crtc_state *vcs = kzalloc(sizeof(*vcs), GFP_KERNEL);
- vcs = kzalloc(sizeof(*vcs), GFP_KERNEL);
-
- if (!vcs) {
- DRM_ERROR("Cannot allocate vmw_crtc_state\n");
- return;
- }
+ if (crtc->state)
+ vmw_du_crtc_destroy_state(crtc, crtc->state);
- crtc->state = &vcs->base;
- crtc->state->crtc = crtc;
+ __drm_atomic_helper_crtc_reset(crtc, &vcs->base);
}
Convert vmwgfx to using __drm_atomic_helper_crtc_reset(), instead of writing its own version. Instead of open coding destroy_state(), call it directly for freeing the old state. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: Thomas Hellstrom <thellstrom@vmware.com> --- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)