Commit c465bbc8 authored by Stefan Brüns's avatar Stefan Brüns Committed by Daniel Vetter

drm/edid: new drm_edid_block_checksum helper function V3

The function will also be used by a later patch, so factor it out.

V2: make raw_edid const, define/declare before first use
V3: fix erroneuos removal of csum variable
Signed-off-by: default avatarStefan Brüns <stefan.bruens@rwth-aachen.de>
Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent da4c07b7
...@@ -1014,6 +1014,16 @@ module_param_named(edid_fixup, edid_fixup, int, 0400); ...@@ -1014,6 +1014,16 @@ module_param_named(edid_fixup, edid_fixup, int, 0400);
MODULE_PARM_DESC(edid_fixup, MODULE_PARM_DESC(edid_fixup,
"Minimum number of valid EDID header bytes (0-8, default 6)"); "Minimum number of valid EDID header bytes (0-8, default 6)");
static int drm_edid_block_checksum(const u8 *raw_edid)
{
int i;
u8 csum = 0;
for (i = 0; i < EDID_LENGTH; i++)
csum += raw_edid[i];
return csum;
}
static bool drm_edid_is_zero(const u8 *in_edid, int length) static bool drm_edid_is_zero(const u8 *in_edid, int length)
{ {
if (memchr_inv(in_edid, 0, length)) if (memchr_inv(in_edid, 0, length))
...@@ -1035,8 +1045,7 @@ static bool drm_edid_is_zero(const u8 *in_edid, int length) ...@@ -1035,8 +1045,7 @@ static bool drm_edid_is_zero(const u8 *in_edid, int length)
*/ */
bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid) bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid)
{ {
int i; u8 csum;
u8 csum = 0;
struct edid *edid = (struct edid *)raw_edid; struct edid *edid = (struct edid *)raw_edid;
if (WARN_ON(!raw_edid)) if (WARN_ON(!raw_edid))
...@@ -1056,8 +1065,7 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid) ...@@ -1056,8 +1065,7 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid)
} }
} }
for (i = 0; i < EDID_LENGTH; i++) csum = drm_edid_block_checksum(raw_edid);
csum += raw_edid[i];
if (csum) { if (csum) {
if (print_bad_edid) { if (print_bad_edid) {
DRM_ERROR("EDID checksum is invalid, remainder is %d\n", csum); DRM_ERROR("EDID checksum is invalid, remainder is %d\n", csum);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment