[Intel-gfx] [PATCH 10/11] drm/i915: Simplify error handling in __intel_set_mode()
Ander Conselvan de Oliveira
ander.conselvan.de.oliveira at intel.com
Fri Apr 10 01:38:39 PDT 2015
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.
---
drivers/gpu/drm/i915/intel_display.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index b249133..06f3b83 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -11633,10 +11633,8 @@ static int __intel_set_mode(struct drm_crtc *crtc,
return ret;
crtc_state_copy = kmalloc(sizeof(*crtc_state_copy), GFP_KERNEL);
- if (!crtc_state_copy) {
- ret = -ENOMEM;
- goto done;
- }
+ if (!crtc_state_copy)
+ return -ENOMEM;
for_each_intel_crtc_in_state(state, intel_crtc, crtc_state, i) {
if (!needs_modeset(crtc_state))
@@ -11703,19 +11701,14 @@ static int __intel_set_mode(struct drm_crtc *crtc,
}
/* FIXME: add subpixel order */
-done:
- if (ret == 0 && pipe_config) {
- struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
- /* The pipe_config will be freed with the atomic state, so
- * make a copy. */
- memcpy(crtc_state_copy, intel_crtc->config,
- sizeof *crtc_state_copy);
- intel_crtc->config = crtc_state_copy;
- intel_crtc->base.state = &crtc_state_copy->base;
- } else {
- kfree(crtc_state_copy);
- }
+ intel_crtc = to_intel_crtc(crtc);
+
+ /* The pipe_config will be freed with the atomic state, so
+ * make a copy. */
+ memcpy(crtc_state_copy, intel_crtc->config, sizeof *crtc_state_copy);
+ intel_crtc->config = crtc_state_copy;
+ intel_crtc->base.state = &crtc_state_copy->base;
return ret;
}
--
2.1.0
More information about the Intel-gfx
mailing list