From patchwork Thu Jun 15 22:37:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 9790419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 26851602CB for ; Fri, 16 Jun 2017 00:53:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18288284F6 for ; Fri, 16 Jun 2017 00:53:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D0092860B; Fri, 16 Jun 2017 00:53:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BC7AE284F6 for ; Fri, 16 Jun 2017 00:53:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 043436E84A; Fri, 16 Jun 2017 00:53:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from gateway34.websitewelcome.com (gateway34.websitewelcome.com [192.185.148.119]) by gabe.freedesktop.org (Postfix) with ESMTPS id AC52B6E766 for ; Thu, 15 Jun 2017 22:37:55 +0000 (UTC) Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway34.websitewelcome.com (Postfix) with ESMTP id EA3B19F9AE for ; Thu, 15 Jun 2017 17:37:54 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id LdOSdXcagybc3LdOSdZgUg; Thu, 15 Jun 2017 17:37:36 -0500 Received: from [189.152.192.143] (port=48600 helo=embeddedgus) by gator4166.hostgator.com with esmtpa (Exim 4.87) (envelope-from ) id 1dLdOk-004IyR-Ip; Thu, 15 Jun 2017 17:37:54 -0500 Date: Thu, 15 Jun 2017 17:37:53 -0500 From: "Gustavo A. R. Silva" To: Alex Deucher , Christian =?iso-8859-1?Q?K=F6nig?= , David Airlie Subject: [PATCH] drm/radeon: remove unnecessary variable in si_enable_smc_cac Message-ID: <20170615223753.GA15833@embeddedgus> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - lists.freedesktop.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.152.192.143 X-Exim-ID: 1dLdOk-004IyR-Ip X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedgus) [189.152.192.143]:48600 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 5 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Mailman-Approved-At: Fri, 16 Jun 2017 00:53:09 +0000 Cc: "Gustavo A. R. Silva" , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org 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-Virus-Scanned: ClamAV using ClamSMTP Remove unnecessary variable smc_result and simplify the logic related. Variable smc_result is only being used to store the return value of function si_send_msg_to_smc() and then compare this value against constant PPSMC_Result_OK. In other cases this variable is not even used after storing a value in it (lines of code 2833 and 2838). Besides, by removing this variable the logic can be simplified and the number of nested IF statements reduced. Addresses-Coverity-ID: 1226969 Signed-off-by: Gustavo A. R. Silva --- drivers/gpu/drm/radeon/si_dpm.c | 49 ++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c index ee3e742..09ef41f 100644 --- a/drivers/gpu/drm/radeon/si_dpm.c +++ b/drivers/gpu/drm/radeon/si_dpm.c @@ -2800,42 +2800,37 @@ static int si_enable_smc_cac(struct radeon_device *rdev, { struct ni_power_info *ni_pi = ni_get_pi(rdev); struct si_power_info *si_pi = si_get_pi(rdev); - PPSMC_Result smc_result; int ret = 0; if (ni_pi->enable_cac) { - if (enable) { - if (!si_should_disable_uvd_powertune(rdev, radeon_new_state)) { - if (ni_pi->support_cac_long_term_average) { - smc_result = si_send_msg_to_smc(rdev, PPSMC_CACLongTermAvgEnable); - if (smc_result != PPSMC_Result_OK) - ni_pi->support_cac_long_term_average = false; - } - - smc_result = si_send_msg_to_smc(rdev, PPSMC_MSG_EnableCac); - if (smc_result != PPSMC_Result_OK) { - ret = -EINVAL; - ni_pi->cac_enabled = false; - } else { - ni_pi->cac_enabled = true; - } - - if (si_pi->enable_dte) { - smc_result = si_send_msg_to_smc(rdev, PPSMC_MSG_EnableDTE); - if (smc_result != PPSMC_Result_OK) - ret = -EINVAL; - } + if (enable && + !si_should_disable_uvd_powertune(rdev, radeon_new_state)) { + if (ni_pi->support_cac_long_term_average && + PPSMC_Result_OK != + si_send_msg_to_smc(rdev, PPSMC_CACLongTermAvgEnable)) + ni_pi->support_cac_long_term_average = false; + + if (si_send_msg_to_smc(rdev, PPSMC_MSG_EnableCac) != + PPSMC_Result_OK) { + ret = -EINVAL; + ni_pi->cac_enabled = false; + } else { + ni_pi->cac_enabled = true; } - } else if (ni_pi->cac_enabled) { - if (si_pi->enable_dte) - smc_result = si_send_msg_to_smc(rdev, PPSMC_MSG_DisableDTE); - smc_result = si_send_msg_to_smc(rdev, PPSMC_MSG_DisableCac); + if (si_pi->enable_dte && + si_send_msg_to_smc(rdev, PPSMC_MSG_EnableDTE) != + PPSMC_Result_OK) + ret = -EINVAL; + } else if (!enable && ni_pi->cac_enabled) { + if (si_pi->enable_dte) + si_send_msg_to_smc(rdev, PPSMC_MSG_DisableDTE); + si_send_msg_to_smc(rdev, PPSMC_MSG_DisableCac); ni_pi->cac_enabled = false; if (ni_pi->support_cac_long_term_average) - smc_result = si_send_msg_to_smc(rdev, PPSMC_CACLongTermAvgDisable); + si_send_msg_to_smc(rdev, PPSMC_CACLongTermAvgDisable); } } return ret;