From patchwork Thu Apr 14 15:06:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12813663 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 16A27C4332F for ; Thu, 14 Apr 2022 15:08:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E92F510FD0A; Thu, 14 Apr 2022 15:08:36 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id C94B910FD0A; Thu, 14 Apr 2022 15:08:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649948913; x=1681484913; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=s2NOXR/knAlXxwdsPOtoM6zmnlRRdX1WGQLUAEQwwJk=; b=HoZXLJTuGzbgh9AvniaZSv3VBvQAAEyK7Z0QyamjBsBLsmP3cR+it5ZH uU8IwrCS8hfTC0dJgjjKjw9bW09NPjwVXIwKfIIlMJkgpLmR1AOGVvfqz eC/yNIGCl25PJiHjw4pPBfHx1VDnKHJO1LPp4OOgYLmWMzUPRBxni4Yih ON2MZAc1saAHit5gFr8pWfpHLbrLLuZQX6qIF5O6/81Zl7iXxNGKF39uI TAiQxxqz70r9Vp1Or9nMjeEpexSZvDy/objhPpADyC5v98c99kKkW3T9/ fpEZgIYn56luUvUIZyUzMroaq9AmYZYpmD0E6YlCu7tk8XDNmgXN1BhXf A==; X-IronPort-AV: E=McAfee;i="6400,9594,10317"; a="262394778" X-IronPort-AV: E=Sophos;i="5.90,260,1643702400"; d="scan'208";a="262394778" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2022 08:08:33 -0700 X-IronPort-AV: E=Sophos;i="5.90,260,1643702400"; d="scan'208";a="591219314" Received: from nplaweck-mobl.ger.corp.intel.com (HELO localhost) ([10.249.149.236]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2022 08:08:30 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Subject: [PATCH 15/19] drm/edid: restore some type safety to cea_db_*() functions Date: Thu, 14 Apr 2022 18:06:58 +0300 Message-Id: <8bca14cf89ad475380b45525fd1e3b553184db72.1649948563.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 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" During the transition, we accepted a void pointer for a poor C programmer's version of polymorphism. Switch the functions to use struct cea_db * to regain some more type safety. Cc: Ville Syrjälä Signed-off-by: Jani Nikula --- drivers/gpu/drm/drm_edid.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 7ed0258c0edf..1fc4e8754cd4 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -4408,11 +4408,8 @@ struct cea_db { u8 data[]; } __packed; -static int cea_db_tag(const void *_db) +static int cea_db_tag(const struct cea_db *db) { - /* FIXME: Transition to passing struct cea_db * everywhere. */ - const struct cea_db *db = _db; - return db->tag_length >> 5; } @@ -4579,47 +4576,47 @@ static void cea_db_iter_end(struct cea_db_iter *iter) memset(iter, 0, sizeof(*iter)); } -static bool cea_db_is_hdmi_vsdb(const void *db) +static bool cea_db_is_hdmi_vsdb(const struct cea_db *db) { return cea_db_is_vendor(db, HDMI_IEEE_OUI) && cea_db_payload_len(db) >= 5; } -static bool cea_db_is_hdmi_forum_vsdb(const void *db) +static bool cea_db_is_hdmi_forum_vsdb(const struct cea_db *db) { return cea_db_is_vendor(db, HDMI_FORUM_IEEE_OUI) && cea_db_payload_len(db) >= 7; } -static bool cea_db_is_microsoft_vsdb(const void *db) +static bool cea_db_is_microsoft_vsdb(const struct cea_db *db) { return cea_db_is_vendor(db, MICROSOFT_IEEE_OUI) && cea_db_payload_len(db) == 21; } -static bool cea_db_is_vcdb(const void *db) +static bool cea_db_is_vcdb(const struct cea_db *db) { return cea_db_is_extended_tag(db, CTA_EXT_DB_VIDEO_CAP) && cea_db_payload_len(db) == 2; } -static bool cea_db_is_hdmi_forum_scdb(const void *db) +static bool cea_db_is_hdmi_forum_scdb(const struct cea_db *db) { return cea_db_is_extended_tag(db, CTA_EXT_DB_HF_SCDB) && cea_db_payload_len(db) >= 7; } -static bool cea_db_is_y420cmdb(const void *db) +static bool cea_db_is_y420cmdb(const struct cea_db *db) { return cea_db_is_extended_tag(db, CTA_EXT_DB_420_VIDEO_CAP_MAP); } -static bool cea_db_is_y420vdb(const void *db) +static bool cea_db_is_y420vdb(const struct cea_db *db) { return cea_db_is_extended_tag(db, CTA_EXT_DB_420_VIDEO_DATA); } -static bool cea_db_is_hdmi_hdr_metadata_block(const void *db) +static bool cea_db_is_hdmi_hdr_metadata_block(const struct cea_db *db) { return cea_db_is_extended_tag(db, CTA_EXT_DB_HDR_STATIC_METADATA) && cea_db_payload_len(db) >= 3;