From patchwork Thu Mar 31 18:44:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12797566 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 F3696C433F5 for ; Thu, 31 Mar 2022 18:45:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E394710F469; Thu, 31 Mar 2022 18:45:35 +0000 (UTC) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 49F6810F468; Thu, 31 Mar 2022 18:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648752334; x=1680288334; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=thJY/9WcRjrK/MbaJPNaDU4CAUOw2XR84H9CWbT0JPo=; b=fdqyAeYeV2P9I4U2sjhCZy3yde/1gVcWSuKoU62NzWMFq1jPqUpwrV20 2ipflfJs6Aydn51eD1o/nYy0hZHRA8i5en+10gu9UfPqZf6CPC6PDy7iJ o3Ilz6CLD1SXm+hRy2Wprn46wHFEhHjOtkyqYEGmpcnLldU096kjvCWDO 1fy9BLaNd0cuTWRdYbI9zBXHgihL6ppWgxqOvAnXoj1PpQrIsAoMIX5GW 0tBl/hVEkiFPmwmxaI1JlGp3mIZKk1idf+UoYfflwzPzXzIQ47JhUrnIp QIy1rHzjqjAitDV2IEhMh7WTimbaBsN7a3WqOM5gAkVRdkFcwa5aWQyX5 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10302"; a="284846217" X-IronPort-AV: E=Sophos;i="5.90,225,1643702400"; d="scan'208";a="284846217" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2022 11:45:23 -0700 X-IronPort-AV: E=Sophos;i="5.90,225,1643702400"; d="scan'208";a="547458000" Received: from gluca-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.48.194]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2022 11:45:21 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Thu, 31 Mar 2022 21:44:59 +0300 Message-Id: <36641401c8eb0e403c0e33365ff4ad9a28f9fd4a.1648752228.git.jani.nikula@intel.com> 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 Subject: [Intel-gfx] [PATCH v2 02/12] drm/edid: clean up EDID block checksum functions X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Have two clear functions, one to compute the checksum over the EDID, and another to get the checksum from the EDID. Throw away the diff function. Ditch the drm_ prefix for static functions, and accept const void * to help transition to struct edid * usage. Cc: Ville Syrjälä Signed-off-by: Jani Nikula Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/drm_edid.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 5c7065561d4c..82e00650af14 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1597,25 +1597,25 @@ module_param_named(edid_fixup, edid_fixup, int, 0400); MODULE_PARM_DESC(edid_fixup, "Minimum number of valid EDID header bytes (0-8, default 6)"); -static int drm_edid_block_checksum(const u8 *raw_edid) +static int edid_block_compute_checksum(const void *_block) { + const u8 *block = _block; int i; u8 csum = 0, crc = 0; for (i = 0; i < EDID_LENGTH - 1; i++) - csum += raw_edid[i]; + csum += block[i]; crc = 0x100 - csum; return crc; } -static bool drm_edid_block_checksum_diff(const u8 *raw_edid, u8 real_checksum) +static int edid_block_get_checksum(const void *_block) { - if (raw_edid[EDID_LENGTH - 1] != real_checksum) - return true; - else - return false; + const struct edid *block = _block; + + return block->checksum; } static bool drm_edid_is_zero(const u8 *in_edid, int length) @@ -1704,8 +1704,8 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid, } } - csum = drm_edid_block_checksum(raw_edid); - if (drm_edid_block_checksum_diff(raw_edid, csum)) { + csum = edid_block_compute_checksum(raw_edid); + if (csum != edid_block_get_checksum(raw_edid)) { if (edid_corrupt) *edid_corrupt = true; @@ -1859,7 +1859,7 @@ static void connector_bad_edid(struct drm_connector *connector, /* Calculate real checksum for the last edid extension block data */ if (last_block < num_blocks) connector->real_edid_checksum = - drm_edid_block_checksum(edid + last_block * EDID_LENGTH); + edid_block_compute_checksum(edid + last_block * EDID_LENGTH); if (connector->bad_edid_counter++ && !drm_debug_enabled(DRM_UT_KMS)) return;