[Suspend2][ 6/7] [Suspend2] Register and remove proc file functions.

From: Nigel Cunningham
Date: Mon Jun 26 2006 - 12:48:34 EST


Functions to add and remove a Suspend2 proc file entry.

Signed-off-by: Nigel Cunningham <nigel@xxxxxxxxxxxx>

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

diff --git a/kernel/power/proc.c b/kernel/power/proc.c
index dad818f..9722377 100644
--- a/kernel/power/proc.c
+++ b/kernel/power/proc.c
@@ -281,3 +281,47 @@ static void suspend_initialise_proc(void
suspend_register_procfile(&proc_params[i]);
}

+/* suspend_register_procfile
+ *
+ * Helper for registering a new /proc/suspend2 entry.
+ */
+
+struct proc_dir_entry *suspend_register_procfile(
+ struct suspend_proc_data *suspend_proc_data)
+{
+ struct proc_dir_entry *new_entry;
+
+ if (!suspend_proc_initialised)
+ suspend_initialise_proc();
+
+ new_entry = create_proc_entry(
+ suspend_proc_data->filename,
+ suspend_proc_data->permissions,
+ suspend_dir);
+ if (new_entry) {
+ list_add_tail(&suspend_proc_data->proc_data_list, &suspend_proc_entries);
+ new_entry->read_proc = suspend_read_proc;
+ new_entry->write_proc = suspend_write_proc;
+ new_entry->data = suspend_proc_data;
+ } else {
+ printk("Error! create_proc_entry returned NULL.\n");
+ INIT_LIST_HEAD(&suspend_proc_data->proc_data_list);
+ }
+ return new_entry;
+}
+
+/* suspend_unregister_procfile
+ *
+ * Helper for removing unwanted /proc/suspend2 entries.
+ *
+ */
+void suspend_unregister_procfile(struct suspend_proc_data *suspend_proc_data)
+{
+ if (list_empty(&suspend_proc_data->proc_data_list))
+ return;
+
+ remove_proc_entry(
+ suspend_proc_data->filename,
+ suspend_dir);
+ list_del(&suspend_proc_data->proc_data_list);
+}

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