aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power/power.h
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2006-09-26 02:32:46 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-26 11:48:58 -0400
commitfb13a28b0f5ada60861868c4fa48a12bd0cb8dea (patch)
treee0a4611621f2d5abc94f0b0ea5a2c41f2962e5e1 /kernel/power/power.h
parentae83c5eef59ffe6eb61110b8c8fd1ea3e0881712 (diff)
[PATCH] swsusp: struct snapshot_handle cleanup
Add comments describing struct snapshot_handle and its members, change the confusing name of its member 'page' to 'cur'. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Cc: Pavel Machek <pavel@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/power/power.h')
-rw-r--r--kernel/power/power.h64
1 files changed, 56 insertions, 8 deletions
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 59ce712f082d..1cefcf87a694 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -50,17 +50,65 @@ extern asmlinkage int swsusp_arch_resume(void);
50 50
51extern unsigned int count_data_pages(void); 51extern unsigned int count_data_pages(void);
52 52
53/**
54 * Auxiliary structure used for reading the snapshot image data and
55 * metadata from and writing them to the list of page backup entries
56 * (PBEs) which is the main data structure of swsusp.
57 *
58 * Using struct snapshot_handle we can transfer the image, including its
59 * metadata, as a continuous sequence of bytes with the help of
60 * snapshot_read_next() and snapshot_write_next().
61 *
62 * The code that writes the image to a storage or transfers it to
63 * the user land is required to use snapshot_read_next() for this
64 * purpose and it should not make any assumptions regarding the internal
65 * structure of the image. Similarly, the code that reads the image from
66 * a storage or transfers it from the user land is required to use
67 * snapshot_write_next().
68 *
69 * This may allow us to change the internal structure of the image
70 * in the future with considerably less effort.
71 */
72
53struct snapshot_handle { 73struct snapshot_handle {
54 loff_t offset; 74 loff_t offset; /* number of the last byte ready for reading
55 unsigned int page; 75 * or writing in the sequence
56 unsigned int page_offset; 76 */
57 unsigned int prev; 77 unsigned int cur; /* number of the block of PAGE_SIZE bytes the
58 struct pbe *pbe, *last_pbe; 78 * next operation will refer to (ie. current)
59 void *buffer; 79 */
60 unsigned int buf_offset; 80 unsigned int cur_offset; /* offset with respect to the current
61 int sync_read; 81 * block (for the next operation)
82 */
83 unsigned int prev; /* number of the block of PAGE_SIZE bytes that
84 * was the current one previously
85 */
86 struct pbe *pbe; /* PBE that corresponds to 'buffer' */
87 struct pbe *last_pbe; /* When the image is restored (eg. read
88 * from disk) we can store some image
89 * data directly in the page frames
90 * in which they were before suspend.
91 * In such a case the PBEs that
92 * correspond to them will be unused.
93 * This is the last PBE, so far, that
94 * does not correspond to such data.
95 */
96 void *buffer; /* address of the block to read from
97 * or write to
98 */
99 unsigned int buf_offset; /* location to read from or write to,
100 * given as a displacement from 'buffer'
101 */
102 int sync_read; /* Set to one to notify the caller of
103 * snapshot_write_next() that it may
104 * need to call wait_on_bio_chain()
105 */
62}; 106};
63 107
108/* This macro returns the address from/to which the caller of
109 * snapshot_read_next()/snapshot_write_next() is allowed to
110 * read/write data after the function returns
111 */
64#define data_of(handle) ((handle).buffer + (handle).buf_offset) 112#define data_of(handle) ((handle).buffer + (handle).buf_offset)
65 113
66extern int snapshot_read_next(struct snapshot_handle *handle, size_t count); 114extern int snapshot_read_next(struct snapshot_handle *handle, size_t count);