From patchwork Fri Mar 13 16:20:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 11437379 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 856D5921 for ; Fri, 13 Mar 2020 16:21:21 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6E0A02072C for ; Fri, 13 Mar 2020 16:21:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E0A02072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 269116EC13; Fri, 13 Mar 2020 16:21:17 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 93EEC6EC14; Fri, 13 Mar 2020 16:21:14 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Mar 2020 09:21:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,549,1574150400"; d="scan'208";a="290065879" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by FMSMGA003.fm.intel.com with SMTP; 13 Mar 2020 09:21:12 -0700 Received: by stinkbox (sSMTP sendmail emulation); Fri, 13 Mar 2020 18:21:11 +0200 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Subject: [PATCH 5/9] drm/edid: Move validate_displayid() drm_find_displayid_extension() Date: Fri, 13 Mar 2020 18:20:50 +0200 Message-Id: <20200313162054.16009-6-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200313162054.16009-1-ville.syrjala@linux.intel.com> References: <20200313162054.16009-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 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: intel-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä Instead of everyone having to call validate_displayid() let's just have drm_find_displayid_extension() do it for them. Signed-off-by: Ville Syrjälä --- drivers/gpu/drm/drm_edid.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 18c55f3b20de..dbd2e8474c2a 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3216,6 +3216,7 @@ static u8 *drm_find_displayid_extension(const struct edid *edid, int *length, int *idx) { u8 *displayid = drm_find_edid_extension(edid, DISPLAYID_EXT); + int ret; if (!displayid) return NULL; @@ -3223,12 +3224,15 @@ static u8 *drm_find_displayid_extension(const struct edid *edid, *length = EDID_LENGTH; *idx = 1; + ret = validate_displayid(displayid, *length, *idx); + if (ret) + return NULL; + return displayid; } static u8 *drm_find_cea_extension(const struct edid *edid) { - int ret; int length, idx; struct displayid_block *block; u8 *cea; @@ -3244,10 +3248,6 @@ static u8 *drm_find_cea_extension(const struct edid *edid) if (!displayid) return NULL; - ret = validate_displayid(displayid, length, idx); - if (ret) - return NULL; - idx += sizeof(struct displayid_hdr); for_each_displayid_db(displayid, block, idx, length) { if (block->tag == DATA_BLOCK_CTA) { @@ -5189,7 +5189,6 @@ static int add_displayid_detailed_modes(struct drm_connector *connector, struct edid *edid) { u8 *displayid; - int ret; int length, idx; struct displayid_block *block; int num_modes = 0; @@ -5198,10 +5197,6 @@ static int add_displayid_detailed_modes(struct drm_connector *connector, if (!displayid) return 0; - ret = validate_displayid(displayid, length, idx); - if (ret) - return 0; - idx += sizeof(struct displayid_hdr); for_each_displayid_db(displayid, block, idx, length) { switch (block->tag) { @@ -5849,10 +5844,6 @@ static int drm_parse_display_id(struct drm_connector *connector, struct displayid_block *block; int ret; - ret = validate_displayid(displayid, length, idx); - if (ret) - return ret; - idx += sizeof(struct displayid_hdr); for_each_displayid_db(displayid, block, idx, length) { DRM_DEBUG_KMS("block id 0x%x, rev %d, len %d\n",