Commit 9eb45f22 authored by Ander Conselvan de Oliveira's avatar Ander Conselvan de Oliveira Committed by Daniel Vetter

drm/i915: Simplify error handling in __intel_set_mode()

The remaining parts of the failure path could only be reached if the
allocation of crtc_state_copy would fail. In that case, there is nothing
to undo, so just get rid of the label for error handling and return an
error code immediately.

We also always allocate a pipe_config, even if the pipe is being
disabled, so the remaining part of what was the error/done case can be
simplified a little too.

v2: Ignore return value from drm_plane_helper_update(). (Ander)
Signed-off-by: default avatarAnder Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 054518dd
...@@ -12278,10 +12278,8 @@ static int __intel_set_mode(struct drm_crtc *modeset_crtc, ...@@ -12278,10 +12278,8 @@ static int __intel_set_mode(struct drm_crtc *modeset_crtc,
return ret; return ret;
crtc_state_copy = kmalloc(sizeof(*crtc_state_copy), GFP_KERNEL); crtc_state_copy = kmalloc(sizeof(*crtc_state_copy), GFP_KERNEL);
if (!crtc_state_copy) { if (!crtc_state_copy)
ret = -ENOMEM; return -ENOMEM;
goto done;
}
for_each_crtc_in_state(state, crtc, crtc_state, i) { for_each_crtc_in_state(state, crtc, crtc_state, i) {
if (!needs_modeset(crtc_state)) if (!needs_modeset(crtc_state))
...@@ -12337,6 +12335,7 @@ static int __intel_set_mode(struct drm_crtc *modeset_crtc, ...@@ -12337,6 +12335,7 @@ static int __intel_set_mode(struct drm_crtc *modeset_crtc,
hdisplay, vdisplay, hdisplay, vdisplay,
x << 16, y << 16, x << 16, y << 16,
hdisplay << 16, vdisplay << 16); hdisplay << 16, vdisplay << 16);
WARN_ON(ret != 0);
} }
/* Now enable the clocks, plane, pipe, and connectors that we set up. */ /* Now enable the clocks, plane, pipe, and connectors that we set up. */
...@@ -12351,21 +12350,16 @@ static int __intel_set_mode(struct drm_crtc *modeset_crtc, ...@@ -12351,21 +12350,16 @@ static int __intel_set_mode(struct drm_crtc *modeset_crtc,
} }
/* FIXME: add subpixel order */ /* FIXME: add subpixel order */
done:
if (ret == 0 && pipe_config) { intel_crtc = to_intel_crtc(modeset_crtc);
struct intel_crtc *intel_crtc = to_intel_crtc(modeset_crtc);
/* The pipe_config will be freed with the atomic state, so /* The pipe_config will be freed with the atomic state, so
* make a copy. */ * make a copy. */
memcpy(crtc_state_copy, intel_crtc->config, memcpy(crtc_state_copy, intel_crtc->config, sizeof *crtc_state_copy);
sizeof *crtc_state_copy);
intel_crtc->config = crtc_state_copy; intel_crtc->config = crtc_state_copy;
intel_crtc->base.state = &crtc_state_copy->base; intel_crtc->base.state = &crtc_state_copy->base;
} else {
kfree(crtc_state_copy);
}
return ret; return 0;
} }
static int intel_set_mode_with_config(struct drm_crtc *crtc, static int intel_set_mode_with_config(struct drm_crtc *crtc,
......
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