340d7b3b11daee8dae9a96a4bd59e6967dbb4114
[platform/kernel/u-boot.git] / lib / tables_csum.c
1 /*
2  * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6
7 #include <common.h>
8 #include <linux/ctype.h>
9
10 u8 table_compute_checksum(void *v, int len)
11 {
12         u8 *bytes = v;
13         u8 checksum = 0;
14         int i;
15
16         for (i = 0; i < len; i++)
17                 checksum -= bytes[i];
18
19         return checksum;
20 }