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: Zhen Lei X-Patchwork-Id: 448842 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp314225jac; Thu, 27 May 2021 02:04:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzC/OHj+0Zh8t+LmBMUEBIKbvX0PhQk/hzejC0xfimpMW4F4qQ58ueUhERw7UFR2r3PRhxE X-Received: by 2002:a17:902:b609:b029:ec:e80d:7ebd with SMTP id b9-20020a170902b609b02900ece80d7ebdmr2350119pls.75.1622106299127; Thu, 27 May 2021 02:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622106299; cv=none; d=google.com; s=arc-20160816; b=x9cej3ZUOifmiGAoT6ffU3FZW5hPkM9CeGf1Arxg89ic7Whzp0fEatzp9OjbKouZE0 aI2IWZiTExbCKM6YS5j5RwbIKj06zedQXHCQTMfvYx6r/37FlbJCuXUbPj9BBUdIokz/ Y7sRmgoAAe83essGn1Zxbl08JFmoa9+/1wzjOE8DAV4WWNALhFnGysyCkMex7d7FgObd 4mX9xoz5F9vn1x4feGjL/2JnyJ8W24vqChB9YoBBzy6hHKShLiJjdcWkbYVCJvsv4W+o KaZfZZc/S73Qf61C90Xr/DoCujD8iVj4AY5iFNaHiodoECxJH6NVkpLcaG9jU5g1Vd6O fPfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:delivered-to; bh=fBPlaHu5NyqnSs7Ijv/jR+KSP9iL89A3sVmoO8q5+Cw=; b=p8PJAaVg93NDaZyXvKxkopgkOIZDrNqTDsKRLARmpfJhOX24E7f9cNbhoOnfMucoyI kkZI3K/w91ORBqcouSg+BxllFPmwPA0hNOXeEhfBLpcfPzktAbaxUt1iklBzde2TYH90 guTYUNnB9YeKwOFRXacEOcubZ5rjbsByt89IkwgsGnzm8wFBf68lqAFjodhs/QfMw6oT /pCAXd2CUkEcBSA9A4TKYm0LTto14/yfzsisfeGH17MiSXfF/5LYwpBU/+CQ17cW4Cnq x3c7Mxs5Z28M7BM8J4iHIp8FnuXFOaIMws2geAPW9XSyreVZbhcQ1X6AGX8/W+UOT1wk C81A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id i6si2366809pgg.552.2021.05.27.02.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 02:04:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com 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) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org 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(-) -- 2.25.1 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; }