mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/
synced 2026-04-17 22:23:45 -04:00
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:
committed by
Steven Rostedt (VMware)
parent
0ff2bb7d42
commit
99f4f5d623
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user