diff options
author | Masami Hiramatsu <mhiramat@kernel.org> | 2021-06-02 11:19:34 +0300 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2021-06-10 20:41:26 +0300 |
commit | 99f4f5d62338cab9dcf45735344541574daedd20 (patch) | |
tree | ba01e7fd496e6f9c07fa89d44efa37efac49e81a /include/linux/bootconfig.h | |
parent | 0ff2bb7d42c36ee60bbf3e60993666a8e0c06a24 (diff) | |
download | linux-99f4f5d62338cab9dcf45735344541574daedd20.tar.xz |
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>
Diffstat (limited to 'include/linux/bootconfig.h')
-rw-r--r-- | include/linux/bootconfig.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/bootconfig.h b/include/linux/bootconfig.h index e49043ac77c9..6bdd94cff4e2 100644 --- a/include/linux/bootconfig.h +++ b/include/linux/bootconfig.h @@ -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; |