lkml.org 
[lkml]   [2006]   [Jun]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[Suspend2][ 04/13] [Suspend2] Compression initialise & cleanup routines.
    Date
    These routines handle the initialisation and cleanup for compression,
    invoking the buffer allocation and cryptoapi setup routines.

    Signed-off-by: Nigel Cunningham <nigel@suspend2.net>

    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@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2006-06-27 07:18    [W:0.021 / U:0.164 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site