From 2b445e4d31940d512b3257f7398b794be710b8a9 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Fri, 19 Aug 2016 01:23:22 +0200 Subject: x86: Move table csum into separate header We need the checksum function without all the other table functionality soon, so let's split it out into its own header file. Signed-off-by: Alexander Graf Reviewed-by: Bin Meng Reviewed-by: Simon Glass --- include/tables_csum.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 include/tables_csum.h (limited to 'include/tables_csum.h') diff --git a/include/tables_csum.h b/include/tables_csum.h new file mode 100644 index 0000000..27d147b --- /dev/null +++ b/include/tables_csum.h @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2015, Bin Meng + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef _TABLES_CSUM_H_ +#define _TABLES_CSUM_H_ + +static inline u8 table_compute_checksum(void *v, int len) +{ + u8 *bytes = v; + u8 checksum = 0; + int i; + + for (i = 0; i < len; i++) + checksum -= bytes[i]; + + return checksum; +} + +#endif -- cgit v1.1