[U-Boot] [PATCH v2 17/41] common: Add a new lz4.h header file

Simon Glass sjg at chromium.org
Fri Nov 8 19:53:24 UTC 2019


Add a header file to house the lz4 compression function. Add a comment
while we are here, since it not even clear from the name what the function
actuall does.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v2: None

 common/image.c     |  1 +
 include/common.h   |  3 ---
 include/lz4.h      | 24 ++++++++++++++++++++++++
 lib/lz4_wrapper.c  |  1 +
 test/compression.c |  1 +
 5 files changed, 27 insertions(+), 3 deletions(-)
 create mode 100644 include/lz4.h

diff --git a/common/image.c b/common/image.c
index 992ebbad51..1c8ac2df70 100644
--- a/common/image.c
+++ b/common/image.c
@@ -20,6 +20,7 @@
 
 #include <gzip.h>
 #include <image.h>
+#include <lz4.h>
 #include <mapmem.h>
 
 #if IMAGE_ENABLE_FIT || IMAGE_ENABLE_OF_LIBFDT
diff --git a/include/common.h b/include/common.h
index f433db17ae..1e77ed393e 100644
--- a/include/common.h
+++ b/include/common.h
@@ -292,9 +292,6 @@ void	wait_ticks    (unsigned long);
 ulong	usec2ticks    (unsigned long usec);
 ulong	ticks2usec    (unsigned long ticks);
 
-/* lib/lz4_wrapper.c */
-int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn);
-
 /* lib/uuid.c */
 #include <uuid.h>
 
diff --git a/include/lz4.h b/include/lz4.h
new file mode 100644
index 0000000000..1276fb98a3
--- /dev/null
+++ b/include/lz4.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2019 Google LLC
+ */
+
+#ifndef __LZ4_H
+#define __LZ4_H
+
+/**
+ * ulz4fn() - Decompress LZ4 data
+ *
+ * @src: Source data to decompress
+ * @srcn: Length of source data
+ * @dst: Destination for uncompressed data
+ * @dstn: Returns length of uncompressed data
+ * @return 0 if OK, -EPROTONOSUPPORT if the magic number or version number are
+ *	not recognised or independent blocks are used, -EINVAL if the reserved
+ *	fields are non-zero, or input is overrun, -EENOBUFS if the destination
+ *	buffer is overrun, -EEPROTO if the compressed data causes an error in
+ *	the decompression algorithm
+ */
+int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn);
+
+#endif
diff --git a/lib/lz4_wrapper.c b/lib/lz4_wrapper.c
index 1c68e67452..1e1e8d5085 100644
--- a/lib/lz4_wrapper.c
+++ b/lib/lz4_wrapper.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <compiler.h>
 #include <image.h>
+#include <lz4.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 
diff --git a/test/compression.c b/test/compression.c
index 08fef59d0a..48dccc0e89 100644
--- a/test/compression.c
+++ b/test/compression.c
@@ -7,6 +7,7 @@
 #include <bootm.h>
 #include <command.h>
 #include <gzip.h>
+#include <lz4.h>
 #include <malloc.h>
 #include <mapmem.h>
 #include <asm/io.h>
-- 
2.24.0.rc1.363.gb1bccd3e3d-goog



More information about the U-Boot mailing list