xref: /openbmc/u-boot/lib/tables_csum.c (revision e8f80a5a)
1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
21befb38bSAlexander Graf /*
31befb38bSAlexander Graf  * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
41befb38bSAlexander Graf  */
51befb38bSAlexander Graf 
61befb38bSAlexander Graf #include <common.h>
71befb38bSAlexander Graf #include <linux/ctype.h>
81befb38bSAlexander Graf 
table_compute_checksum(void * v,int len)91befb38bSAlexander Graf u8 table_compute_checksum(void *v, int len)
101befb38bSAlexander Graf {
111befb38bSAlexander Graf 	u8 *bytes = v;
121befb38bSAlexander Graf 	u8 checksum = 0;
131befb38bSAlexander Graf 	int i;
141befb38bSAlexander Graf 
151befb38bSAlexander Graf 	for (i = 0; i < len; i++)
161befb38bSAlexander Graf 		checksum -= bytes[i];
171befb38bSAlexander Graf 
181befb38bSAlexander Graf 	return checksum;
191befb38bSAlexander Graf }
20