Blob Blame History Raw
From e6a835b52c3235aebff509f9938387dc86aafc09 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= <ville.syrjala@linux.intel.com>
Date: Fri, 13 Mar 2020 18:20:50 +0200
Subject: drm/edid: Move validate_displayid() drm_find_displayid_extension()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Git-commit: ea0aa608a8e89f112761d6f91733f27513d2b657
Patch-mainline: v5.8-rc1
References: jsc#SLE-12680, jsc#SLE-12880, jsc#SLE-12882, jsc#SLE-12883, jsc#SLE-13496, jsc#SLE-15322

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ä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200313162054.16009-6-ville.syrjala@linux.intel.com
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Patrik Jakobsson <pjakobsson@suse.de>
---
 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 1717d57f6b11..1306fd6e686c 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3217,6 +3217,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;
@@ -3224,12 +3225,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;
@@ -3245,10 +3249,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",
-- 
2.28.0