summaryrefslogtreecommitdiff
path: root/tools/bootconfig
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@kernel.org>2021-06-02 17:19:34 +0900
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2021-06-10 13:41:26 -0400
commit99f4f5d62338cab9dcf45735344541574daedd20 (patch)
treeba01e7fd496e6f9c07fa89d44efa37efac49e81a /tools/bootconfig
parent0ff2bb7d42c36ee60bbf3e60993666a8e0c06a24 (diff)
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 'tools/bootconfig')
-rw-r--r--tools/bootconfig/main.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c
index 62a3b5064b17..f45fa992e01d 100644
--- a/tools/bootconfig/main.c
+++ b/tools/bootconfig/main.c
@@ -126,17 +126,6 @@ static void xbc_show_list(void)
}
}
-/* Simple real checksum */
-static int checksum(unsigned char *buf, int len)
-{
- int i, sum = 0;
-
- for (i = 0; i < len; i++)
- sum += buf[i];
-
- return sum;
-}
-
#define PAGE_SIZE 4096
static int load_xbc_fd(int fd, char **buf, int size)
@@ -232,7 +221,7 @@ static int load_xbc_from_initrd(int fd, char **buf)
return ret;
/* Wrong Checksum */
- rcsum = checksum((unsigned char *)*buf, size);
+ rcsum = xbc_calc_checksum(*buf, size);
if (csum != rcsum) {
pr_err("checksum error: %d != %d\n", csum, rcsum);
return -EINVAL;
@@ -381,7 +370,7 @@ static int apply_xbc(const char *path, const char *xbc_path)
return ret;
}
size = strlen(buf) + 1;
- csum = checksum((unsigned char *)buf, size);
+ csum = xbc_calc_checksum(buf, size);
/* Backup the bootconfig data */
data = calloc(size + BOOTCONFIG_ALIGN +