From patchwork Thu Mar 31 18:45:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12797584 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C7129C433F5 for ; Thu, 31 Mar 2022 18:46:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0FEA310F478; Thu, 31 Mar 2022 18:46:04 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4887810F478; Thu, 31 Mar 2022 18:46:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648752363; x=1680288363; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R3p5aWr/Rrgl2uqycgY/KbEOcV+eBKqBaQU3u3ZlCC8=; b=MqER9pRe7yTho1zsxNPDIyKT4i+Lznfy9Gtmz4r3KqY5A5iGt1x56K4d rfvlit17Rwq41PLSqbllrrOwOX2uqtUedlszdmQRU8l76bYxLRGYhoP6C GR0O94mF8vV492THE8HuFVNbUhUv+B4Up0hbQyBI32/G4ys6057YhIFdO rCsYl3uEScqsp76h2GSFWOSwKMwNIjZZPYqMmfVzE5tAkBEeNX53mqGB1 ++Ei8gVCw0wRPm1XY71c8f5aEoEf0/DwD1YU9259CVVgsZg+TTvYJnxWc dFhcDhqcWigo4muNpsG9ekFDEuLRdaynB7BuDcKPY2M7uuHeoVKtbKmg5 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10302"; a="259901204" X-IronPort-AV: E=Sophos;i="5.90,225,1643702400"; d="scan'208";a="259901204" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2022 11:45:54 -0700 X-IronPort-AV: E=Sophos;i="5.90,225,1643702400"; d="scan'208";a="720574442" Received: from gluca-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.48.194]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2022 11:45:53 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 09/12] drm/edid: simplify block check when filtering invalid blocks Date: Thu, 31 Mar 2022 21:45:06 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo 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: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" There's no need to handle complicated scenarios or debug log when filtering blocks that have already been identified as invalid. Simplify by adding an edid_block_valid() helper that operates on const data and prints nothing. (Finally, here's the justification for the previously added separate edid_block_status_valid() function!) Cc: Ville Syrjälä Signed-off-by: Jani Nikula Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/drm_edid.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index a967e6e65ab5..4803033d44fd 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1714,6 +1714,12 @@ static bool edid_block_status_valid(enum edid_block_status status, int tag) (status == EDID_BLOCK_CHECKSUM && tag == CEA_EXT); } +static bool edid_block_valid(const void *block, bool base) +{ + return edid_block_status_valid(edid_block_check(block, base), + edid_block_tag(block)); +} + /** * drm_edid_block_valid - Sanity check the EDID block (base or extension) * @raw_edid: pointer to raw EDID block @@ -2080,7 +2086,7 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, for (i = 0; i <= edid->extensions; i++) { void *block = edid + i; - if (!drm_edid_block_valid(block, i, false, NULL)) + if (!edid_block_valid(block, i == 0)) continue; memcpy(dest_block, block, EDID_LENGTH);