Commit 2b445e4d31940d512b3257f7398b794be710b8a9

Authored by Alexander Graf
Committed by Bin Meng
1 parent d5a815327d

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 <agraf@suse.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

Showing 3 changed files with 24 additions and 12 deletions Side-by-side Diff

arch/x86/include/asm/tables.h
... ... @@ -7,6 +7,8 @@
7 7 #ifndef _X86_TABLES_H_
8 8 #define _X86_TABLES_H_
9 9  
  10 +#include <tables_csum.h>
  11 +
10 12 /*
11 13 * All x86 tables happen to like the address range from 0xf0000 to 0x100000.
12 14 * We use 0xf0000 as the starting address to store those tables, including
arch/x86/lib/tables.c
... ... @@ -38,18 +38,6 @@
38 38 #endif
39 39 };
40 40  
41   -u8 table_compute_checksum(void *v, int len)
42   -{
43   - u8 *bytes = v;
44   - u8 checksum = 0;
45   - int i;
46   -
47   - for (i = 0; i < len; i++)
48   - checksum -= bytes[i];
49   -
50   - return checksum;
51   -}
52   -
53 41 void table_fill_string(char *dest, const char *src, size_t n, char pad)
54 42 {
55 43 int start, len;
include/tables_csum.h
  1 +/*
  2 + * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
  3 + *
  4 + * SPDX-License-Identifier: GPL-2.0+
  5 + */
  6 +
  7 +#ifndef _TABLES_CSUM_H_
  8 +#define _TABLES_CSUM_H_
  9 +
  10 +static inline 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 +}
  21 +
  22 +#endif