[Suspend2][ 07/11] [Suspend2] Move a suspend2 module to the tail of its list.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When suspend2 modules are built as kernel modules, they may be loaded in a
different order when resuming to the order used when suspending. This could
result in decryption and decompression being done in the wrong order. We
avoid this by remembering the order used when suspending, and reordering at
resume-time to match. This routine provides the primitive used in that
reordering.

Signed-off-by: Nigel Cunningham <[email protected]>

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

diff --git a/kernel/power/modules.c b/kernel/power/modules.c
index 6305fa2..af237b6 100644
--- a/kernel/power/modules.c
+++ b/kernel/power/modules.c
@@ -187,3 +187,38 @@ void suspend_unregister_module(struct su
 	list_del(&module->module_list);
 	suspend_num_modules--;
 }
+
+/*
+ * suspend_move_module_tail
+ *
+ * Rearrange modules when reloading the config.
+ */
+void suspend_move_module_tail(struct suspend_module_ops *module)
+{
+	switch (module->type) {
+		case FILTER_MODULE:
+			if (suspend_num_filters > 1)
+				list_move_tail(&module->type_list,
+						&suspend_filters);
+			break;
+
+		case WRITER_MODULE:
+			if (suspend_num_writers > 1)
+				list_move_tail(&module->type_list,
+						&suspend_writers);
+			break;
+		
+		case MISC_MODULE:
+			break;
+		default:
+			printk("Hmmm. Module '%s' has an invalid type."
+				" It has been ignored.\n", module->name);
+			return;
+	}
+	if ((suspend_num_filters + suspend_num_writers) > 1)
+		list_move_tail(&module->module_list, &suspend_modules);
+}
+
+	return len;
+}
+

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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux