Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp370223pxj; Thu, 27 May 2021 02:06:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyW6L8mGrsqSWUCr/pt0vte9LdmuGsO6P36KZQUl9JUTWTCfrhdjguM69mYyMANIyxp0YI X-Received: by 2002:aa7:db44:: with SMTP id n4mr2986786edt.374.1622106402816; Thu, 27 May 2021 02:06:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622106402; cv=none; d=google.com; s=arc-20160816; b=xflFkAzni0WIDKpEBYD27jZMeFuvxHs70FRBDESJ+GSkcNSsGAQJ5Loz0uX4mgjwyi sQwtasrhmXX47p1OG7cKiS08wr0SjM3vpyCckfPo7F1DlyGiKOnkkwbyHEj/IOgM/5xS WA0vHblRhreQclWaKi3A1GGsLiRTijhxrdepKJFbPlN5oOjTZlbT7y45orQcivAzqNx9 aCGVz+k9h0secWruu69QzIIB46KmRYPxu82j0rpz2TMPHv6aNyxFFys72H2kZq2qUklT 5usxlEPkSPBuaTUw98bzGA0RKIkB8lo17IHpqZy+4hNPVN3uRlVIFndXYcPZd4Pwb+Ia xKQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=fBPlaHu5NyqnSs7Ijv/jR+KSP9iL89A3sVmoO8q5+Cw=; b=SdtJvnbqRz4tjr/T1Hbtgge1ib5ac6JpOvPWPHVi3xu3x4Y1K39YquwBllA6GuObuX 0mAmtUTkSxLmjVNBJJ7LFRPrHMClp0pRNLNQeO6u+HAiDB6GUlXxaTMADM5kDGbMgnjN OZB6LSW4i5Y7X0RpQxaN2VcfDpbd+CKqO4ou5KJupIZ6BsWdW/K6BzhM/nblurTbwrAj +2f7mzGwlDkMHgZx2Sy6BuyQux9byCa087VqbMyd44A2fLRntJz8pLbpMu1nRzMUxJF/ r41Hp3lnoCXT199wCzD78RRJyFj8ae0vbQ8cd+UI0bCG7115LuAunrI6dSJD6+nn9q14 yK3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz3si1546713ejb.9.2021.05.27.02.06.19; Thu, 27 May 2021 02:06:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235655AbhE0JG2 (ORCPT + 99 others); Thu, 27 May 2021 05:06:28 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:5111 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235537AbhE0JG1 (ORCPT ); Thu, 27 May 2021 05:06:27 -0400 Received: from dggeml711-chm.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4FrMJj4VvKzYn5K; Thu, 27 May 2021 17:02:13 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggeml711-chm.china.huawei.com (10.3.17.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 27 May 2021 17:04:53 +0800 Received: from thunder-town.china.huawei.com (10.174.177.72) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 27 May 2021 17:04:52 +0800 From: Zhen Lei To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , intel-gfx , dri-devel , linux-kernel CC: Zhen Lei Subject: [PATCH 1/1] drm/i915/hdcp: Simplify code in intel_hdcp_auth_downstream() Date: Thu, 27 May 2021 17:04:21 +0800 Message-ID: <20210527090421.9172-1-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.177.72] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If intel_hdcp_validate_v_prime() has been successful within the allowed number of tries, we can directly call drm_dbg_kms() and "goto out" without jumping out of the loop and repeatedly judging whether the operation is successful. This can help us reduce an unnecessary if judgment. And it's a little clearer to read. No functional change. Signed-off-by: Zhen Lei --- drivers/gpu/drm/i915/display/intel_hdcp.c | 24 ++++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c index d8570e14fe60..c32a854eda66 100644 --- a/drivers/gpu/drm/i915/display/intel_hdcp.c +++ b/drivers/gpu/drm/i915/display/intel_hdcp.c @@ -663,13 +663,13 @@ int intel_hdcp_auth_downstream(struct intel_connector *connector) ret = shim->read_ksv_fifo(dig_port, num_downstream, ksv_fifo); if (ret) - goto err; + goto out; if (drm_hdcp_check_ksvs_revoked(&dev_priv->drm, ksv_fifo, num_downstream) > 0) { drm_err(&dev_priv->drm, "Revoked Ksv(s) in ksv_fifo\n"); ret = -EPERM; - goto err; + goto out; } /* @@ -680,20 +680,16 @@ int intel_hdcp_auth_downstream(struct intel_connector *connector) ret = intel_hdcp_validate_v_prime(connector, shim, ksv_fifo, num_downstream, bstatus); - if (!ret) - break; - } - - if (i == tries) { - drm_dbg_kms(&dev_priv->drm, - "V Prime validation failed.(%d)\n", ret); - goto err; + if (!ret) { + drm_dbg_kms(&dev_priv->drm, + "HDCP is enabled (%d downstream devices)\n", + num_downstream); + goto out; + } } - drm_dbg_kms(&dev_priv->drm, "HDCP is enabled (%d downstream devices)\n", - num_downstream); - ret = 0; -err: + drm_dbg_kms(&dev_priv->drm, "V Prime validation failed.(%d)\n", ret); +out: kfree(ksv_fifo); return ret; } -- 2.25.1