aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/drm_edid.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index a71ed935f1c4..2c1d2e49fb6f 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -1014,6 +1014,16 @@ module_param_named(edid_fixup, edid_fixup, int, 0400);
1014MODULE_PARM_DESC(edid_fixup, 1014MODULE_PARM_DESC(edid_fixup,
1015 "Minimum number of valid EDID header bytes (0-8, default 6)"); 1015 "Minimum number of valid EDID header bytes (0-8, default 6)");
1016 1016
1017static int drm_edid_block_checksum(const u8 *raw_edid)
1018{
1019 int i;
1020 u8 csum = 0;
1021 for (i = 0; i < EDID_LENGTH; i++)
1022 csum += raw_edid[i];
1023
1024 return csum;
1025}
1026
1017static bool drm_edid_is_zero(const u8 *in_edid, int length) 1027static bool drm_edid_is_zero(const u8 *in_edid, int length)
1018{ 1028{
1019 if (memchr_inv(in_edid, 0, length)) 1029 if (memchr_inv(in_edid, 0, length))
@@ -1035,8 +1045,7 @@ static bool drm_edid_is_zero(const u8 *in_edid, int length)
1035 */ 1045 */
1036bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid) 1046bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid)
1037{ 1047{
1038 int i; 1048 u8 csum;
1039 u8 csum = 0;
1040 struct edid *edid = (struct edid *)raw_edid; 1049 struct edid *edid = (struct edid *)raw_edid;
1041 1050
1042 if (WARN_ON(!raw_edid)) 1051 if (WARN_ON(!raw_edid))
@@ -1056,8 +1065,7 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid)
1056 } 1065 }
1057 } 1066 }
1058 1067
1059 for (i = 0; i < EDID_LENGTH; i++) 1068 csum = drm_edid_block_checksum(raw_edid);
1060 csum += raw_edid[i];
1061 if (csum) { 1069 if (csum) {
1062 if (print_bad_edid) { 1070 if (print_bad_edid) {
1063 DRM_ERROR("EDID checksum is invalid, remainder is %d\n", csum); 1071 DRM_ERROR("EDID checksum is invalid, remainder is %d\n", csum);