UPSTREAM: GPU-DRM: Delete unnecessary checks before drm_property_unreference_blob()
authorMarkus Elfring <elfring@users.sourceforge.net>
Fri, 6 Nov 2015 11:03:46 +0000 (12:03 +0100)
committerHuang, Tao <huangtao@rock-chips.com>
Fri, 7 Jul 2017 11:09:07 +0000 (19:09 +0800)
The drm_property_unreference_blob() function tests whether its argument
is NULL and then returns immediately.
Thus the tests around the calls are not needed.

This issue was detected by using the Coccinelle software.

Link: http://patchwork.freedesktop.org/patch/msgid/563C8B3E.405@users.sourceforge.net
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
(cherry picked from commit 5f911905054a64cf8c7871fddd33f4af74f07a17)

Change-Id: I599721227294c7cde5fd4f2ef6d5a97212b61b77
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
drivers/gpu/drm/drm_atomic.c
drivers/gpu/drm/drm_atomic_helper.c

index 938d331701a5d007b241ce396da97e2041748b0e..fb47e2547df865f0f706912ac31bc8af24f71b5b 100644 (file)
@@ -316,8 +316,7 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,
        if (mode && memcmp(&state->mode, mode, sizeof(*mode)) == 0)
                return 0;
 
-       if (state->mode_blob)
-               drm_property_unreference_blob(state->mode_blob);
+       drm_property_unreference_blob(state->mode_blob);
        state->mode_blob = NULL;
 
        if (mode) {
@@ -363,8 +362,7 @@ int drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state *state,
        if (blob == state->mode_blob)
                return 0;
 
-       if (state->mode_blob)
-               drm_property_unreference_blob(state->mode_blob);
+       drm_property_unreference_blob(state->mode_blob);
        state->mode_blob = NULL;
 
        memset(&state->mode, 0, sizeof(state->mode));
@@ -420,8 +418,7 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
                struct drm_property_blob *mode =
                        drm_property_lookup_blob(dev, val);
                ret = drm_atomic_set_mode_prop_for_crtc(state, mode);
-               if (mode)
-                       drm_property_unreference_blob(mode);
+               drm_property_unreference_blob(mode);
                return ret;
        }
        else if (crtc->funcs->atomic_set_property)
index d5524917e7c4de36e24961d9285447e494e4dcc2..3b19a596e7d1f9f5815be8461f8dc11f64296b69 100644 (file)
@@ -2367,7 +2367,7 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_dpms);
  */
 void drm_atomic_helper_crtc_reset(struct drm_crtc *crtc)
 {
-       if (crtc->state && crtc->state->mode_blob)
+       if (crtc->state)
                drm_property_unreference_blob(crtc->state->mode_blob);
        kfree(crtc->state);
        crtc->state = kzalloc(sizeof(*crtc->state), GFP_KERNEL);
@@ -2435,8 +2435,7 @@ EXPORT_SYMBOL(drm_atomic_helper_crtc_duplicate_state);
 void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc *crtc,
                                            struct drm_crtc_state *state)
 {
-       if (state->mode_blob)
-               drm_property_unreference_blob(state->mode_blob);
+       drm_property_unreference_blob(state->mode_blob);
 }
 EXPORT_SYMBOL(__drm_atomic_helper_crtc_destroy_state);