From patchwork Thu May 27 09:04:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 12283803 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E360CC47089 for ; Thu, 27 May 2021 09:04:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 978F261402 for ; Thu, 27 May 2021 09:04:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 978F261402 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F1DCC6EE3D; Thu, 27 May 2021 09:04:57 +0000 (UTC) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2ED036EE3D for ; Thu, 27 May 2021 09:04:56 +0000 (UTC) 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 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhen Lei Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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; }