[Suspend2][ 04/13] [Suspend2] Compression initialise & cleanup routines.

From: Nigel Cunningham
Date: Tue Jun 27 2006 - 01:13:48 EST


These routines handle the initialisation and cleanup for compression,
invoking the buffer allocation and cryptoapi setup routines.

Signed-off-by: Nigel Cunningham <nigel@xxxxxxxxxxxx>

kernel/power/compression.c | 59 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/kernel/power/compression.c b/kernel/power/compression.c
index 470644f..44d46be 100644
--- a/kernel/power/compression.c
+++ b/kernel/power/compression.c
@@ -129,3 +129,62 @@ static int suspend_compress_crypto_prepa
return 0;
}

+/*
+ * suspend_compress_write_cleanup(): Write unflushed data and free workspace.
+ *
+ * Returns: Result of writing last page.
+ */
+static int suspend_compress_rw_cleanup(int rw)
+{
+ int ret = 0;
+
+ if (rw == WRITE && suspend_compressor_transform)
+ ret = next_driver->write_chunk(virt_to_page(local_buffer));
+
+ suspend_compress_cleanup();
+ suspend_compress_free_local_buffer();
+
+ return ret;
+}
+
+/*
+ * suspend_compress_rw_init()
+ * @stream_number: Ignored.
+ *
+ * Allocate buffers and prepare to compress data.
+ * Returns: Zero on success, -ENOMEM if unable to vmalloc.
+ */
+static int suspend_compress_rw_init(int rw, int stream_number)
+{
+ int result;
+
+ next_driver = suspend_get_next_filter(&suspend_compression_ops);
+
+ if (!next_driver) {
+ printk("Compression Driver: Argh! Nothing follows me in"
+ " the pipeline!");
+ return -ECHILD;
+ }
+
+ if ((result = suspend_compress_crypto_prepare() ||
+ suspend_compression_ops.disabled))
+ return result;
+
+ if ((result = suspend_compress_allocate_local_buffer()))
+ return result;
+
+ if (rw == READ)
+ bufofs = PAGE_SIZE;
+ else {
+ /* Only reset the stats if starting to write an image */
+ if (stream_number == 2)
+ bytes_in = bytes_out = 0;
+
+ bufofs = 0;
+ }
+
+ position = 0;
+
+ return 0;
+}
+

--
Nigel Cunningham nigel at suspend2 dot net
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/