From patchwork Fri Nov 6 11:13:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 7576231 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0E21D9F36A for ; Sat, 7 Nov 2015 18:38:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ACF202060C for ; Sat, 7 Nov 2015 18:38:23 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C98232053A for ; Sat, 7 Nov 2015 18:38:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 922D46E44B; Sat, 7 Nov 2015 10:38:17 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 310 seconds by postgrey-1.34 at gabe; Fri, 06 Nov 2015 03:18:19 PST Received: from mout.web.de (mout.web.de [212.227.17.12]) by gabe.freedesktop.org (Postfix) with ESMTPS id 31AC96E1CD for ; Fri, 6 Nov 2015 03:18:18 -0800 (PST) Received: from [192.168.1.2] ([78.49.86.198]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0Lo0V2-1aN85Q3LUO-00fygp; Fri, 06 Nov 2015 12:13:04 +0100 Subject: [PATCH] GPU-DRM: Delete unnecessary checks before drm_property_unreference_blob() To: Daniel Vetter , David Airlie , dri-devel@lists.freedesktop.org References: <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> <55998CD5.3080204@users.sourceforge.net> <20150706065346.GA2156@phenom.ffwll.local> From: SF Markus Elfring X-Enigmail-Draft-Status: N1110 Message-ID: <563C8B3E.405@users.sourceforge.net> Date: Fri, 6 Nov 2015 12:13:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20150706065346.GA2156@phenom.ffwll.local> X-Provags-ID: V03:K0:BO2o3JoHJ3OY+tKk43CcArs57kwnoT7o35RpOJ1HjntmBIgGjn4 oSgorgCxCGTGMXQx+UNGsnMI4wktChIVowcr8qvGXH/jCNJTDmIwas3LTXWOOgGsqTT5p/u HrwuKtS0bmdY0JXAEmHhlNrxdi667KE/ebvQZu3qIU7fHubFGrMSrJGR6Hj4sPr7VpRHmzE V8AF+XPbhmWs7LgH+nkYg== X-UI-Out-Filterresults: notjunk:1; V01:K0:6hBhR62wocU=:8iB83Fj4dBMTKBXczyZ0If jkgt4eP0LTuJgG0Cbl6Hh2AN8N3pCqOHeNoNpMjcXWeNfs9Yjwql64EfiU7bnfC1b9Hs1vLIP tr+/9VeslUqlIrxuSLnYjPCLH1R6zA1K1/PzZx0EhVzLFO2fFhMkHpS3hQRC/MGXtgCK5bsw5 pITsuNun/llHGSsiFvVNbpG/u7WGA5mIee/0jC0aK5J6Ar/di4mFzeq/hTTjIX+uUlj601KJy tlieOaVgShxnoK3wEhVJGuXiU8YbNRLwSj49Lhji6yTMpT9h4kxJESp71VOOyT9HEVdwodTsY UvVp1ViD759rF9N/9e1RMeyFxUFLTAAbAvXesWNglUuX32TVkKz+amDnH41aosoURJzl0WmW6 L/UnrPnvjsX+bdpn7WAbfFnyhFdINoiXKVKRfnEN9iZXumRYtezMuVPTvs6wpAqsmRotSD5m6 yRwCYqTwuKVJbI1E4lBo5aXL/d3PA9Vr2/dQxpDNPR2zhnugCVbT2SfEXp2i3m4aImrfcgUFI 4Cl74s08ekKHjbI+huHjagClqlSP0h1+3EfeINem3y4OQhvJxlub8+ZSuolf52bS58z27A5vz zl1Z6cRtrpXe4JEMtntqGPiOex6RDlRPlCjKSk+Jn0jY8EvR8Ngr+U0zzHrr8Vfk3cqY/jjou Hi+tuPxEQFG1G29tsfUlYMOSx0liy5oAPKKusKOy95PxhbiMqRgpGL6vd88VCiGCfCmBA7b6u GNIvvE/FXFy8M1CosTIjWfRg2Z7sX2pl8SMY/ys3XmlL0h9NRO7FJTbSpD4Ms4SHKtCihIQs9 Ab0JiAf X-Mailman-Approved-At: Sat, 07 Nov 2015 10:38:13 -0800 Cc: Julia Lawall , Junwang Zhao , kernel-janitors@vger.kernel.org, LKML X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Fri, 6 Nov 2015 12:03:46 +0100 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. Signed-off-by: Markus Elfring --- drivers/gpu/drm/drm_atomic.c | 9 +++------ drivers/gpu/drm/drm_atomic_helper.c | 5 ++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 7bb3845..d65dc31 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -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; if (blob) { @@ -419,8 +417,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) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 0c6f621..9870c70 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -2173,7 +2173,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); @@ -2241,8 +2241,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);