Commit cb3bee03 authored by Geliang Tang's avatar Geliang Tang Committed by Kees Cook

pstore: Use crypto compress API

In the pstore compression part, we use zlib/lzo/lz4/lz4hc/842
compression algorithm API to implement pstore compression backends. But
there are many repeat codes in these implementations. This patch uses
crypto compress API to simplify these codes.

1) rewrite allocate_buf_for_compression, free_buf_for_compression,
pstore_compress, pstore_decompress functions using crypto compress API.
2) drop compress, decompress, allocate, free functions in pstore_zbackend,
and add zbufsize function to get each different compress buffer size.
3) use late_initcall to call ramoops_init later, to make sure the crypto
subsystem has already initialized.
4) use 'unsigned int' type instead of 'size_t' in pstore_compress,
pstore_decompress functions' length arguments.
5) rename 'zlib' to 'deflate' to follow the crypto API's name convention.
Signed-off-by: default avatarGeliang Tang <geliangtang@gmail.com>
[kees: tweaked error messages on allocation failures and Kconfig help]
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
parent f2531f19
...@@ -12,51 +12,47 @@ config PSTORE ...@@ -12,51 +12,47 @@ config PSTORE
If you don't have a platform persistent store driver, If you don't have a platform persistent store driver,
say N. say N.
config PSTORE_ZLIB_COMPRESS config PSTORE_DEFLATE_COMPRESS
bool "ZLIB compression" bool "DEFLATE (ZLIB) compression"
default y default y
depends on PSTORE depends on PSTORE
select ZLIB_DEFLATE select CRYPTO_DEFLATE
select ZLIB_INFLATE
help help
This option enables ZLIB compression algorithm support. This option enables DEFLATE (also known as ZLIB) compression
algorithm support.
config PSTORE_LZO_COMPRESS config PSTORE_LZO_COMPRESS
bool "LZO compression" bool "LZO compression"
depends on PSTORE depends on PSTORE
select LZO_COMPRESS select CRYPTO_LZO
select LZO_DECOMPRESS
help help
This option enables LZO compression algorithm support. This option enables LZO compression algorithm support.
config PSTORE_LZ4_COMPRESS config PSTORE_LZ4_COMPRESS
bool "LZ4 compression" bool "LZ4 compression"
depends on PSTORE depends on PSTORE
select LZ4_COMPRESS select CRYPTO_LZ4
select LZ4_DECOMPRESS
help help
This option enables LZ4 compression algorithm support. This option enables LZ4 compression algorithm support.
config PSTORE_LZ4HC_COMPRESS config PSTORE_LZ4HC_COMPRESS
bool "LZ4HC compression" bool "LZ4HC compression"
depends on PSTORE depends on PSTORE
select LZ4HC_COMPRESS select CRYPTO_LZ4HC
select LZ4_DECOMPRESS
help help
This option enables LZ4HC (high compression) mode algorithm. This option enables LZ4HC (high compression) mode algorithm.
config PSTORE_842_COMPRESS config PSTORE_842_COMPRESS
bool "842 compression" bool "842 compression"
depends on PSTORE depends on PSTORE
select 842_COMPRESS select CRYPTO_842
select 842_DECOMPRESS
help help
This option enables 842 compression algorithm support. This option enables 842 compression algorithm support.
config PSTORE_COMPRESS config PSTORE_COMPRESS
def_bool y def_bool y
depends on PSTORE depends on PSTORE
depends on PSTORE_ZLIB_COMPRESS || PSTORE_LZO_COMPRESS || \ depends on PSTORE_DEFLATE_COMPRESS || PSTORE_LZO_COMPRESS || \
PSTORE_LZ4_COMPRESS || PSTORE_LZ4HC_COMPRESS || \ PSTORE_LZ4_COMPRESS || PSTORE_LZ4HC_COMPRESS || \
PSTORE_842_COMPRESS PSTORE_842_COMPRESS
...@@ -69,12 +65,12 @@ choice ...@@ -69,12 +65,12 @@ choice
the kernel command line. the kernel command line.
Currently, pstore has support for 5 compression algorithms: Currently, pstore has support for 5 compression algorithms:
zlib, lzo, lz4, lz4hc and 842. deflate, lzo, lz4, lz4hc and 842.
The default compression algorithm is zlib. The default compression algorithm is deflate.
config PSTORE_ZLIB_COMPRESS_DEFAULT config PSTORE_DEFLATE_COMPRESS_DEFAULT
bool "zlib" if PSTORE_ZLIB_COMPRESS=y bool "deflate" if PSTORE_DEFLATE_COMPRESS=y
config PSTORE_LZO_COMPRESS_DEFAULT config PSTORE_LZO_COMPRESS_DEFAULT
bool "lzo" if PSTORE_LZO_COMPRESS=y bool "lzo" if PSTORE_LZO_COMPRESS=y
...@@ -93,7 +89,7 @@ endchoice ...@@ -93,7 +89,7 @@ endchoice
config PSTORE_COMPRESS_DEFAULT config PSTORE_COMPRESS_DEFAULT
string string
depends on PSTORE_COMPRESS depends on PSTORE_COMPRESS
default "zlib" if PSTORE_ZLIB_COMPRESS_DEFAULT default "deflate" if PSTORE_DEFLATE_COMPRESS_DEFAULT
default "lzo" if PSTORE_LZO_COMPRESS_DEFAULT default "lzo" if PSTORE_LZO_COMPRESS_DEFAULT
default "lz4" if PSTORE_LZ4_COMPRESS_DEFAULT default "lz4" if PSTORE_LZ4_COMPRESS_DEFAULT
default "lz4hc" if PSTORE_LZ4HC_COMPRESS_DEFAULT default "lz4hc" if PSTORE_LZ4HC_COMPRESS_DEFAULT
......
This diff is collapsed.
...@@ -938,7 +938,7 @@ static int __init ramoops_init(void) ...@@ -938,7 +938,7 @@ static int __init ramoops_init(void)
ramoops_register_dummy(); ramoops_register_dummy();
return platform_driver_register(&ramoops_driver); return platform_driver_register(&ramoops_driver);
} }
postcore_initcall(ramoops_init); late_initcall(ramoops_init);
static void __exit ramoops_exit(void) static void __exit ramoops_exit(void)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment