aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2007-08-30 21:19:05 +0000
committerRafael J. Wysocki <rjw@sisk.pl>2007-08-30 21:19:05 +0000
commit5ad1dbd92dc5c83d4d408d96fdf3f0f9e468fa84 (patch)
tree8c3d1a96ec906c9d625e95286a7ec46767712ac5
parente832c8c05d3e897e809d1aabdf64908c9e7c03c3 (diff)
downloadsuspend-utils-5ad1dbd92dc5c83d4d408d96fdf3f0f9e468fa84.tar.gz
Clean up the code in suspend.c (part 6).
-rw-r--r--suspend.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/suspend.c b/suspend.c
index f0eb3fb..4e5d76d 100644
--- a/suspend.c
+++ b/suspend.c
@@ -282,21 +282,30 @@ init_swap_writer(struct swap_map_handle *handle, int dev, int fd, void *buf)
{
if (!buf)
return -EINVAL;
+
handle->areas = buf;
- handle->areas_per_page = (page_size - sizeof(loff_t)) /
- sizeof(struct swap_area);
- handle->next_swap = (loff_t *)(handle->areas + handle->areas_per_page);
- handle->page_buffer = (char *)buf + page_size;
- handle->write_buffer = handle->page_buffer + page_size;
- buf = handle->write_buffer + buffer_size;
+ buf += page_size;
+
+ handle->page_buffer = buf;
+ buf += page_size;
+
+ handle->write_buffer = buf;
+ buf += buffer_size;
+
#ifdef CONFIG_COMPRESS
handle->lzo_work_buffer = buf;
buf += LZO1X_1_MEM_COMPRESS;
#endif
+
#ifdef CONFIG_ENCRYPT
handle->encrypt_buffer = buf;
#endif
+
memset(handle->areas, 0, page_size);
+ handle->areas_per_page = (page_size - sizeof(loff_t)) /
+ sizeof(struct swap_area);
+ handle->next_swap = (loff_t *)(handle->areas + handle->areas_per_page);
+
handle->cur_swap = get_swap_page(dev);
if (!handle->cur_swap)
return -ENOSPC;
@@ -306,10 +315,13 @@ init_swap_writer(struct swap_map_handle *handle, int dev, int fd, void *buf)
handle->cur_area.size = 0;
handle->cur_alloc = page_size;
handle->k = 0;
+
handle->dev = dev;
handle->fd = fd;
+
if (compute_checksum)
md5_init_ctx(&handle->ctx);
+
return 0;
}