From: Nigel Cunningham <nigel@suspend2.net>
To: linux-kernel@vger.kernel.org
Subject: [Suspend2][ 11/19] [Suspend2] Write module configurations in an image header.
Date: Tue, 27 Jun 2006 08:36:36 +1000 [thread overview]
Message-ID: <20060626223634.4219.43499.stgit@nigel.suspend2.net> (raw)
In-Reply-To: <20060626223557.4219.53030.stgit@nigel.suspend2.net>
Write the configuration of each module used to the image header.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/io.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 67 insertions(+), 0 deletions(-)
diff --git a/kernel/power/io.c b/kernel/power/io.c
index dade1fc..a0aabd1 100644
--- a/kernel/power/io.c
+++ b/kernel/power/io.c
@@ -421,3 +421,70 @@ static int read_pageset(struct pagedir *
return result;
}
+/* write_module_configs()
+ *
+ * Description: Store the configuration for each module in the image header.
+ * Returns: Int: Zero on success, Error value otherwise.
+ */
+static int write_module_configs(void)
+{
+ struct suspend_module_ops *this_module;
+ char *buffer = (char *) get_zeroed_page(GFP_ATOMIC);
+ int len, index = 1;
+ struct suspend_module_header suspend_module_header;
+
+ if (!buffer) {
+ printk("Failed to allocate a buffer for saving "
+ "module configuration info.\n");
+ return -ENOMEM;
+ }
+
+ /*
+ * We have to know which data goes with which module, so we at
+ * least write a length of zero for a module. Note that we are
+ * also assuming every module's config data takes <= PAGE_SIZE.
+ */
+
+ /* For each module (in registration order) */
+ list_for_each_entry(this_module, &suspend_modules, module_list) {
+ if (this_module->disabled || !this_module->storage_needed ||
+ (this_module->type == WRITER_MODULE &&
+ suspend_active_writer != this_module))
+ continue;
+
+ /* Get the data from the module */
+ len = 0;
+ if (this_module->save_config_info)
+ len = this_module->save_config_info(buffer);
+
+ /* Save the details of the module */
+ suspend_module_header.disabled = this_module->disabled;
+ suspend_module_header.type = this_module->type;
+ suspend_module_header.index = index++;
+ strncpy(suspend_module_header.name, this_module->name,
+ sizeof(suspend_module_header.name));
+ suspend_active_writer->rw_header_chunk(WRITE,
+ this_module,
+ (char *) &suspend_module_header,
+ sizeof(suspend_module_header));
+
+ /* Save the size of the data and any data returned */
+ suspend_active_writer->rw_header_chunk(WRITE,
+ this_module,
+ (char *) &len, sizeof(int));
+ if (len)
+ suspend_active_writer->rw_header_chunk(
+ WRITE, this_module, buffer, len);
+ }
+
+ /* Write a blank header to terminate the list */
+ suspend_module_header.name[0] = '\0';
+ suspend_active_writer->rw_header_chunk(WRITE,
+ NULL,
+ (char *) &suspend_module_header,
+ sizeof(suspend_module_header));
+
+ free_page((unsigned long) buffer);
+ return 0;
+}
+
--
Nigel Cunningham nigel at suspend2 dot net
next prev parent reply other threads:[~2006-06-26 23:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-26 22:35 [Suspend2][ 00/19] Highlevel I/O routines Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 01/19] [Suspend2] Core io.c header Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 02/19] [Suspend2] Attempt to parse resume device Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 03/19] [Suspend2] Attempt to parse resume device (wrapped) Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 04/19] [Suspend2] Reset modules after invalidating an image Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 05/19] [Suspend2] Fill the suspend header fields Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 06/19] [Suspend2] Initialise modules before doing I/O Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 07/19] [Suspend2] Cleanup modules after doing I/O on a portion of the image Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 08/19] [Suspend2] I/O main loop Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 09/19] [Suspend2] Write a pageset Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 10/19] [Suspend2] Read a portion of the image from storage Nigel Cunningham
2006-06-26 22:36 ` Nigel Cunningham [this message]
2006-06-26 22:36 ` [Suspend2][ 12/19] [Suspend2] Read module configs from an image header Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 13/19] [Suspend2] Write " Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 14/19] [Suspend2] Sanity check " Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 15/19] [Suspend2] Core of code for reading pageset1 Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 16/19] [Suspend2] Read pageset1 Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 17/19] [Suspend2] Get image_exists data Nigel Cunningham
2006-06-26 22:36 ` [Suspend2][ 18/19] [Suspend2] Read pageset2 Nigel Cunningham
2006-06-26 22:37 ` [Suspend2][ 19/19] [Suspend2] I/O header file Nigel Cunningham
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060626223634.4219.43499.stgit@nigel.suspend2.net \
--to=nigel@suspend2.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome