bootconfig: Share the checksum function with tools

Move the checksum calculation function into the header for sharing it
with tools/bootconfig.

Link: https://lkml.kernel.org/r/162262197470.264090.16325743685807878807.stgit@devnote2

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
Masami Hiramatsu
2021-06-02 17:19:34 +09:00
committed by Steven Rostedt (VMware)
parent 0ff2bb7d42
commit 99f4f5d623
3 changed files with 23 additions and 24 deletions

View File

@@ -16,6 +16,26 @@
#define BOOTCONFIG_ALIGN (1 << BOOTCONFIG_ALIGN_SHIFT)
#define BOOTCONFIG_ALIGN_MASK (BOOTCONFIG_ALIGN - 1)
/**
* xbc_calc_checksum() - Calculate checksum of bootconfig
* @data: Bootconfig data.
* @size: The size of the bootconfig data.
*
* Calculate the checksum value of the bootconfig data.
* The checksum will be used with the BOOTCONFIG_MAGIC and the size for
* embedding the bootconfig in the initrd image.
*/
static inline __init u32 xbc_calc_checksum(void *data, u32 size)
{
unsigned char *p = data;
u32 ret = 0;
while (size--)
ret += *p++;
return ret;
}
/* XBC tree node */
struct xbc_node {
u16 next;