Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp638104pxj; Thu, 27 May 2021 08:21:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq7BAZ6KcBpCguU9GRIn0ZYQvPnWeeQKjwRc7vWXRkYxHeyHi9Ztia25N+qi4yY8Rkgoqh X-Received: by 2002:a92:d282:: with SMTP id p2mr3362436ilp.143.1622128907547; Thu, 27 May 2021 08:21:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622128907; cv=none; d=google.com; s=arc-20160816; b=1E6dQkBWJa2q0yB/O7/mbvqkYLoZ89ZDy2s4siaWxLK9b9LFmHYnS5mZyeHNro6S1v xE+iTjISnSeRk+DK9EHhsAEh+tSilLVeKNlAOlQlbomEdEjZwEt4v8uKL2oC9FZ9PqYe k7mH0Z6zUQDgWkXPtJbWHwipc5nqe94j11ExGwzK2D7naRzNF/6VJzJExKiq6GoC6tkl uJDU1bjQgPiJ/ZCyHLtk31cTBhmBR5m2qqHZCT9au/a4lfPcL+6YQt4aYY5wOjRP+9I6 KPEsFVXt9DpOqBz1u2CUxTRHS2/SwnNhoYOFLnEYti6tpVNu5nUVIKgSvXvvt/jdg7DJ xvmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=YvAQd+P61LFSF53nQWGhqonyLjxrPr31JtP1WFyogNI=; b=j86GARbP+LKIqLbio53KAD7YIqIHo5mSCAIXE0O33CCdpRKcJWn+BPOhlEDnd1K2Bl x4zk8WTg9m4FC2TvZu0kPiMhDxGr7TC6wJ0iMtNhD+UQ5JHfkzCg7e4SZrk1IfClDJa3 kQJPEKAV3V17qUf9ZZUoq/ySGevWDXI+gQSakQlR9QYuNmNTzdOXNCXPSwg/mb/JvG/k MJBo9pn2DwrpS1q6wKRpPa/fEjs4UzkMnyzzD2OD4aAY6BeP8txttse5y8y8DjtLJPrJ Nw1DA77QEL5/3uuhkwNkQqhoiHt7tm66boQwq9l1BLwu5yia7NF3QP2dy1v9/Cdjpi3d ho6A== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p8si2372618ils.114.2021.05.27.08.21.33; Thu, 27 May 2021 08:21:47 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236068AbhE0KFy (ORCPT + 99 others); Thu, 27 May 2021 06:05:54 -0400 Received: from mga18.intel.com ([134.134.136.126]:4589 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235768AbhE0KFx (ORCPT ); Thu, 27 May 2021 06:05:53 -0400 IronPort-SDR: s/N7sflE8d6Q9TECp+BIHLh1AxrRq4YPgYDamQ8qTbTAipdFxutsXIp+ji2c0DPHzeSDuXvW6u swMLTveAyPOQ== X-IronPort-AV: E=McAfee;i="6200,9189,9996"; a="190069620" X-IronPort-AV: E=Sophos;i="5.82,334,1613462400"; d="scan'208";a="190069620" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 May 2021 03:04:19 -0700 IronPort-SDR: W5C8h0ho+YxsKWciWBWStpIEd2Gn3EVlQk7BfRGTlX8nCU9S/FRdyUtFro7VMeQU46OVyCe3B4 6pV2ZrVgIuww== X-IronPort-AV: E=Sophos;i="5.82,334,1613462400"; d="scan'208";a="477421498" Received: from ebenabu-mobl.ger.corp.intel.com (HELO localhost) ([10.252.55.22]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 May 2021 03:04:14 -0700 From: Jani Nikula To: Zhen Lei , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , intel-gfx , dri-devel , linux-kernel Cc: Zhen Lei Subject: Re: [PATCH 1/1] drm/i915/hdcp: Simplify code in intel_hdcp_auth_downstream() In-Reply-To: <20210527090421.9172-1-thunder.leizhen@huawei.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20210527090421.9172-1-thunder.leizhen@huawei.com> Date: Thu, 27 May 2021 13:04:11 +0300 Message-ID: <87sg28a3xg.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 27 May 2021, Zhen Lei wrote: > 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. Generally I think the "happy day scenario" should be at the topmost indentation level and not buried in the ifs with a goto exit. BR, Jani. > > 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; > } -- Jani Nikula, Intel Open Source Graphics Center