summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2014-11-24 13:47:13 +0100
committerHans de Goede <hdegoede@redhat.com>2015-01-14 14:56:38 +0100
commite745d064b441dbf48eac4bc2c494263d54262dec (patch)
tree8a8013e88fa5f3ac9c2143fc1f204c50f837bcc5 /common
parentb7ce12ddd7a7aba80fc8f10a50bfdec4f3aceb52 (diff)
downloadtalos-obmc-uboot-e745d064b441dbf48eac4bc2c494263d54262dec.tar.gz
talos-obmc-uboot-e745d064b441dbf48eac4bc2c494263d54262dec.zip
edid: Add an edid_check_checksum() helper function
Add a helper function to check the checksum of an EDID data block. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Anatolij Gustschin <agust@denx.de>
Diffstat (limited to 'common')
-rw-r--r--common/edid.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/common/edid.c b/common/edid.c
index e66108f24a..df797fcdd5 100644
--- a/common/edid.c
+++ b/common/edid.c
@@ -12,6 +12,7 @@
#include <common.h>
#include <edid.h>
+#include <errno.h>
#include <linux/ctype.h>
#include <linux/string.h>
@@ -29,6 +30,17 @@ int edid_check_info(struct edid1_info *edid_info)
return 0;
}
+int edid_check_checksum(u8 *edid_block)
+{
+ u8 checksum = 0;
+ int i;
+
+ for (i = 0; i < 128; i++)
+ checksum += edid_block[i];
+
+ return (checksum == 0) ? 0 : -EINVAL;
+}
+
int edid_get_ranges(struct edid1_info *edid, unsigned int *hmin,
unsigned int *hmax, unsigned int *vmin,
unsigned int *vmax)
OpenPOWER on IntegriCloud